summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-04-11 14:13:31 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-05-16 08:52:39 -0400
commit47b4913050a320bfba55fa65d52d9ba15488bc70 (patch)
tree7b97d0a03104a21e0df8911cda102113982632d5 /src/backend/utils
parent21c2c3d75e888a578176616aa1411552f43b4908 (diff)
Fix new warnings from GCC 7
This addresses the new warning types -Wformat-truncation -Wformat-overflow that are part of -Wall, via -Wformat, in GCC 7.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/dbsize.c14
-rw-r--r--src/backend/utils/cache/relcache.c4
-rw-r--r--src/backend/utils/error/elog.c2
-rw-r--r--src/backend/utils/time/snapmgr.c4
4 files changed, 12 insertions, 12 deletions
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index 3167bad92b0..74cdbb05510 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -41,7 +41,7 @@ db_dir_size(const char *path)
int64 dirsize = 0;
struct dirent *direntry;
DIR *dirdesc;
- char filename[MAXPGPATH];
+ char filename[MAXPGPATH * 2];
dirdesc = AllocateDir(path);
@@ -58,7 +58,7 @@ db_dir_size(const char *path)
strcmp(direntry->d_name, "..") == 0)
continue;
- snprintf(filename, MAXPGPATH, "%s/%s", path, direntry->d_name);
+ snprintf(filename, sizeof(filename), "%s/%s", path, direntry->d_name);
if (stat(filename, &fst) < 0)
{
@@ -86,7 +86,7 @@ calculate_database_size(Oid dbOid)
DIR *dirdesc;
struct dirent *direntry;
char dirpath[MAXPGPATH];
- char pathname[MAXPGPATH];
+ char pathname[MAXPGPATH + 12 + sizeof(TABLESPACE_VERSION_DIRECTORY)];
AclResult aclresult;
/* User must have connect privilege for target database */
@@ -98,7 +98,7 @@ calculate_database_size(Oid dbOid)
/* Shared storage in pg_global is not counted */
/* Include pg_default storage */
- snprintf(pathname, MAXPGPATH, "base/%u", dbOid);
+ snprintf(pathname, sizeof(pathname), "base/%u", dbOid);
totalsize = db_dir_size(pathname);
/* Scan the non-default tablespaces */
@@ -118,7 +118,7 @@ calculate_database_size(Oid dbOid)
strcmp(direntry->d_name, "..") == 0)
continue;
- snprintf(pathname, MAXPGPATH, "pg_tblspc/%s/%s/%u",
+ snprintf(pathname, sizeof(pathname), "pg_tblspc/%s/%s/%u",
direntry->d_name, TABLESPACE_VERSION_DIRECTORY, dbOid);
totalsize += db_dir_size(pathname);
}
@@ -166,7 +166,7 @@ static int64
calculate_tablespace_size(Oid tblspcOid)
{
char tblspcPath[MAXPGPATH];
- char pathname[MAXPGPATH];
+ char pathname[MAXPGPATH * 2];
int64 totalsize = 0;
DIR *dirdesc;
struct dirent *direntry;
@@ -208,7 +208,7 @@ calculate_tablespace_size(Oid tblspcOid)
strcmp(direntry->d_name, "..") == 0)
continue;
- snprintf(pathname, MAXPGPATH, "%s/%s", tblspcPath, direntry->d_name);
+ snprintf(pathname, sizeof(pathname), "%s/%s", tblspcPath, direntry->d_name);
if (stat(pathname, &fst) < 0)
{
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8c8ef66c8f4..95ff838ceaf 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -5525,7 +5525,7 @@ RelationCacheInitFileRemove(void)
const char *tblspcdir = "pg_tblspc";
DIR *dir;
struct dirent *de;
- char path[MAXPGPATH];
+ char path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY)];
/*
* We zap the shared cache file too. In theory it can't get out of sync
@@ -5567,7 +5567,7 @@ RelationCacheInitFileRemoveInDir(const char *tblspcpath)
{
DIR *dir;
struct dirent *de;
- char initfilename[MAXPGPATH];
+ char initfilename[MAXPGPATH * 2];
/* Scan the tablespace directory to find per-database directories */
dir = AllocateDir(tblspcpath);
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 69649290da2..eace0ac1000 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2228,7 +2228,7 @@ static void
setup_formatted_log_time(void)
{
pg_time_t stamp_time;
- char msbuf[8];
+ char msbuf[13];
if (!saved_timeval_set)
{
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 2b7fda7c636..de6441b2701 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1569,7 +1569,7 @@ XactHasExportedSnapshots(void)
void
DeleteAllExportedSnapshotFiles(void)
{
- char buf[MAXPGPATH];
+ char buf[MAXPGPATH + sizeof(SNAPSHOT_EXPORT_DIR)];
DIR *s_dir;
struct dirent *s_de;
@@ -1590,7 +1590,7 @@ DeleteAllExportedSnapshotFiles(void)
strcmp(s_de->d_name, "..") == 0)
continue;
- snprintf(buf, MAXPGPATH, SNAPSHOT_EXPORT_DIR "/%s", s_de->d_name);
+ snprintf(buf, sizeof(buf), SNAPSHOT_EXPORT_DIR "/%s", s_de->d_name);
/* Again, unlink failure is not worthy of FATAL */
if (unlink(buf))
elog(LOG, "could not unlink file \"%s\": %m", buf);