summaryrefslogtreecommitdiff
path: root/src/backend/storage
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/storage
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/storage')
-rw-r--r--src/backend/storage/file/copydir.c10
-rw-r--r--src/backend/storage/file/fd.c12
-rw-r--r--src/backend/storage/file/reinit.c8
-rw-r--r--src/backend/storage/ipc/dsm.c4
4 files changed, 17 insertions, 17 deletions
diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
index a51ee815662..a964e47f502 100644
--- a/src/backend/storage/file/copydir.c
+++ b/src/backend/storage/file/copydir.c
@@ -38,8 +38,8 @@ copydir(char *fromdir, char *todir, bool recurse)
{
DIR *xldir;
struct dirent *xlde;
- char fromfile[MAXPGPATH];
- char tofile[MAXPGPATH];
+ char fromfile[MAXPGPATH * 2];
+ char tofile[MAXPGPATH * 2];
if (mkdir(todir, S_IRWXU) != 0)
ereport(ERROR,
@@ -63,8 +63,8 @@ copydir(char *fromdir, char *todir, bool recurse)
strcmp(xlde->d_name, "..") == 0)
continue;
- snprintf(fromfile, MAXPGPATH, "%s/%s", fromdir, xlde->d_name);
- snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
+ snprintf(fromfile, sizeof(fromfile), "%s/%s", fromdir, xlde->d_name);
+ snprintf(tofile, sizeof(tofile), "%s/%s", todir, xlde->d_name);
if (lstat(fromfile, &fst) < 0)
ereport(ERROR,
@@ -103,7 +103,7 @@ copydir(char *fromdir, char *todir, bool recurse)
strcmp(xlde->d_name, "..") == 0)
continue;
- snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
+ snprintf(tofile, sizeof(tofile), "%s/%s", todir, xlde->d_name);
/*
* We don't need to sync subdirectories here since the recursive
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 170e773c4a4..b07628fd7b2 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -2654,7 +2654,7 @@ CleanupTempFiles(bool isProcExit)
void
RemovePgTempFiles(void)
{
- char temp_path[MAXPGPATH];
+ char temp_path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY) + sizeof(PG_TEMP_FILES_DIR)];
DIR *spc_dir;
struct dirent *spc_de;
@@ -2702,7 +2702,7 @@ RemovePgTempFilesInDir(const char *tmpdirname)
{
DIR *temp_dir;
struct dirent *temp_de;
- char rm_path[MAXPGPATH];
+ char rm_path[MAXPGPATH * 2];
temp_dir = AllocateDir(tmpdirname);
if (temp_dir == NULL)
@@ -2743,7 +2743,7 @@ RemovePgTempRelationFiles(const char *tsdirname)
{
DIR *ts_dir;
struct dirent *de;
- char dbspace_path[MAXPGPATH];
+ char dbspace_path[MAXPGPATH * 2];
ts_dir = AllocateDir(tsdirname);
if (ts_dir == NULL)
@@ -2784,7 +2784,7 @@ RemovePgTempRelationFilesInDbspace(const char *dbspacedirname)
{
DIR *dbspace_dir;
struct dirent *de;
- char rm_path[MAXPGPATH];
+ char rm_path[MAXPGPATH * 2];
dbspace_dir = AllocateDir(dbspacedirname);
if (dbspace_dir == NULL)
@@ -2971,7 +2971,7 @@ walkdir(const char *path,
while ((de = ReadDirExtended(dir, path, elevel)) != NULL)
{
- char subpath[MAXPGPATH];
+ char subpath[MAXPGPATH * 2];
struct stat fst;
int sret;
@@ -2981,7 +2981,7 @@ walkdir(const char *path,
strcmp(de->d_name, "..") == 0)
continue;
- snprintf(subpath, MAXPGPATH, "%s/%s", path, de->d_name);
+ snprintf(subpath, sizeof(subpath), "%s/%s", path, de->d_name);
if (process_symlinks)
sret = stat(subpath, &fst);
diff --git a/src/backend/storage/file/reinit.c b/src/backend/storage/file/reinit.c
index 6b98131e543..934cac2debf 100644
--- a/src/backend/storage/file/reinit.c
+++ b/src/backend/storage/file/reinit.c
@@ -48,7 +48,7 @@ typedef struct
void
ResetUnloggedRelations(int op)
{
- char temp_path[MAXPGPATH];
+ char temp_path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY)];
DIR *spc_dir;
struct dirent *spc_de;
MemoryContext tmpctx,
@@ -104,7 +104,7 @@ ResetUnloggedRelationsInTablespaceDir(const char *tsdirname, int op)
{
DIR *ts_dir;
struct dirent *de;
- char dbspace_path[MAXPGPATH];
+ char dbspace_path[MAXPGPATH * 2];
ts_dir = AllocateDir(tsdirname);
if (ts_dir == NULL)
@@ -145,7 +145,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
{
DIR *dbspace_dir;
struct dirent *de;
- char rm_path[MAXPGPATH];
+ char rm_path[MAXPGPATH * 2];
/* Caller must specify at least one operation. */
Assert((op & (UNLOGGED_RELATION_CLEANUP | UNLOGGED_RELATION_INIT)) != 0);
@@ -308,7 +308,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
ForkNumber forkNum;
int oidchars;
char oidbuf[OIDCHARS + 1];
- char srcpath[MAXPGPATH];
+ char srcpath[MAXPGPATH * 2];
char dstpath[MAXPGPATH];
/* Skip anything that doesn't look like a relation data file. */
diff --git a/src/backend/storage/ipc/dsm.c b/src/backend/storage/ipc/dsm.c
index 47f2bea0be3..8affe6711de 100644
--- a/src/backend/storage/ipc/dsm.c
+++ b/src/backend/storage/ipc/dsm.c
@@ -306,9 +306,9 @@ dsm_cleanup_for_mmap(void)
if (strncmp(dent->d_name, PG_DYNSHMEM_MMAP_FILE_PREFIX,
strlen(PG_DYNSHMEM_MMAP_FILE_PREFIX)) == 0)
{
- char buf[MAXPGPATH];
+ char buf[MAXPGPATH + sizeof(PG_DYNSHMEM_DIR)];
- snprintf(buf, MAXPGPATH, PG_DYNSHMEM_DIR "/%s", dent->d_name);
+ snprintf(buf, sizeof(buf), PG_DYNSHMEM_DIR "/%s", dent->d_name);
elog(DEBUG2, "removing file \"%s\"", buf);