Skip to content

Commit 47b4913

Browse files
committed
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.
1 parent 21c2c3d commit 47b4913

File tree

22 files changed

+65
-65
lines changed

22 files changed

+65
-65
lines changed

contrib/pg_standby/pg_standby.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ char *xlogFilePath; /* where we are going to restore to */
5757
char *nextWALFileName; /* the file we need to get from archive */
5858
char *restartWALFileName; /* the file from which we can restart restore */
5959
char *priorWALFileName; /* the file we need to get from archive */
60-
char WALFilePath[MAXPGPATH]; /* the file path including archive */
60+
char WALFilePath[MAXPGPATH * 2]; /* the file path including archive */
6161
char restoreCommand[MAXPGPATH]; /* run this to restore */
6262
char exclusiveCleanupFileName[MAXFNAMELEN]; /* the file we need to
6363
* get from archive */
@@ -259,9 +259,9 @@ CustomizableCleanupPriorWALFiles(void)
259259
strcmp(xlde->d_name + 8, exclusiveCleanupFileName + 8) < 0)
260260
{
261261
#ifdef WIN32
262-
snprintf(WALFilePath, MAXPGPATH, "%s\\%s", archiveLocation, xlde->d_name);
262+
snprintf(WALFilePath, sizeof(WALFilePath), "%s\\%s", archiveLocation, xlde->d_name);
263263
#else
264-
snprintf(WALFilePath, MAXPGPATH, "%s/%s", archiveLocation, xlde->d_name);
264+
snprintf(WALFilePath, sizeof(WALFilePath), "%s/%s", archiveLocation, xlde->d_name);
265265
#endif
266266

267267
if (debug)

src/backend/access/heap/rewriteheap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ CheckPointLogicalRewriteHeap(void)
11941194
XLogRecPtr redo;
11951195
DIR *mappings_dir;
11961196
struct dirent *mapping_de;
1197-
char path[MAXPGPATH];
1197+
char path[MAXPGPATH + 20];
11981198

11991199
/*
12001200
* We start of with a minimum of the last redo pointer. No new decoding
@@ -1225,7 +1225,7 @@ CheckPointLogicalRewriteHeap(void)
12251225
strcmp(mapping_de->d_name, "..") == 0)
12261226
continue;
12271227

1228-
snprintf(path, MAXPGPATH, "pg_logical/mappings/%s", mapping_de->d_name);
1228+
snprintf(path, sizeof(path), "pg_logical/mappings/%s", mapping_de->d_name);
12291229
if (lstat(path, &statbuf) == 0 && !S_ISREG(statbuf.st_mode))
12301230
continue;
12311231

src/backend/access/transam/xlog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,7 +3941,7 @@ CleanupBackupHistory(void)
39413941
{
39423942
DIR *xldir;
39433943
struct dirent *xlde;
3944-
char path[MAXPGPATH];
3944+
char path[MAXPGPATH + sizeof(XLOGDIR)];
39453945

39463946
xldir = AllocateDir(XLOGDIR);
39473947
if (xldir == NULL)
@@ -3959,7 +3959,7 @@ CleanupBackupHistory(void)
39593959
ereport(DEBUG2,
39603960
(errmsg("removing transaction log backup history file \"%s\"",
39613961
xlde->d_name)));
3962-
snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlde->d_name);
3962+
snprintf(path, sizeof(path), XLOGDIR "/%s", xlde->d_name);
39633963
unlink(path);
39643964
XLogArchiveCleanup(xlde->d_name);
39653965
}
@@ -10061,7 +10061,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
1006110061
/* Collect information about all tablespaces */
1006210062
while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
1006310063
{
10064-
char fullpath[MAXPGPATH];
10064+
char fullpath[MAXPGPATH + 10];
1006510065
char linkpath[MAXPGPATH];
1006610066
char *relpath = NULL;
1006710067
int rllen;

src/backend/postmaster/pgstat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ pgstat_reset_remove_files(const char *directory)
569569
{
570570
DIR *dir;
571571
struct dirent *entry;
572-
char fname[MAXPGPATH];
572+
char fname[MAXPGPATH * 2];
573573

574574
dir = AllocateDir(directory);
575575
while ((entry = ReadDir(dir, directory)) != NULL)
@@ -599,7 +599,7 @@ pgstat_reset_remove_files(const char *directory)
599599
strcmp(entry->d_name + nchars, "stat") != 0)
600600
continue;
601601

602-
snprintf(fname, MAXPGPATH, "%s/%s", directory,
602+
snprintf(fname, sizeof(fname), "%s/%s", directory,
603603
entry->d_name);
604604
unlink(fname);
605605
}

src/backend/replication/basebackup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces,
888888
{
889889
DIR *dir;
890890
struct dirent *de;
891-
char pathbuf[MAXPGPATH];
891+
char pathbuf[MAXPGPATH * 2];
892892
struct stat statbuf;
893893
int64 size = 0;
894894

@@ -940,7 +940,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces,
940940
"and should not be used. "
941941
"Try taking another online backup.")));
942942

943-
snprintf(pathbuf, MAXPGPATH, "%s/%s", path, de->d_name);
943+
snprintf(pathbuf, sizeof(pathbuf), "%s/%s", path, de->d_name);
944944

945945
/* Skip postmaster.pid and postmaster.opts in the data directory */
946946
if (strcmp(pathbuf, "./postmaster.pid") == 0 ||

src/backend/replication/logical/reorderbuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2650,7 +2650,7 @@ StartupReorderBuffer(void)
26502650
while ((logical_de = ReadDir(logical_dir, "pg_replslot")) != NULL)
26512651
{
26522652
struct stat statbuf;
2653-
char path[MAXPGPATH];
2653+
char path[MAXPGPATH * 2 + 12];
26542654

26552655
if (strcmp(logical_de->d_name, ".") == 0 ||
26562656
strcmp(logical_de->d_name, "..") == 0)

src/backend/replication/logical/snapbuild.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ CheckPointSnapBuild(void)
18311831
XLogRecPtr redo;
18321832
DIR *snap_dir;
18331833
struct dirent *snap_de;
1834-
char path[MAXPGPATH];
1834+
char path[MAXPGPATH + 21];
18351835

18361836
/*
18371837
* We start of with a minimum of the last redo pointer. No new replication
@@ -1858,7 +1858,7 @@ CheckPointSnapBuild(void)
18581858
strcmp(snap_de->d_name, "..") == 0)
18591859
continue;
18601860

1861-
snprintf(path, MAXPGPATH, "pg_logical/snapshots/%s", snap_de->d_name);
1861+
snprintf(path, sizeof(path), "pg_logical/snapshots/%s", snap_de->d_name);
18621862

18631863
if (lstat(path, &statbuf) == 0 && !S_ISREG(statbuf.st_mode))
18641864
{

src/backend/replication/slot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -918,13 +918,13 @@ StartupReplicationSlots(void)
918918
while ((replication_de = ReadDir(replication_dir, "pg_replslot")) != NULL)
919919
{
920920
struct stat statbuf;
921-
char path[MAXPGPATH];
921+
char path[MAXPGPATH + 12];
922922

923923
if (strcmp(replication_de->d_name, ".") == 0 ||
924924
strcmp(replication_de->d_name, "..") == 0)
925925
continue;
926926

927-
snprintf(path, MAXPGPATH, "pg_replslot/%s", replication_de->d_name);
927+
snprintf(path, sizeof(path), "pg_replslot/%s", replication_de->d_name);
928928

929929
/* we're only creating directories here, skip if it's not our's */
930930
if (lstat(path, &statbuf) == 0 && !S_ISDIR(statbuf.st_mode))
@@ -1148,7 +1148,7 @@ RestoreSlotFromDisk(const char *name)
11481148
{
11491149
ReplicationSlotOnDisk cp;
11501150
int i;
1151-
char path[MAXPGPATH];
1151+
char path[MAXPGPATH + 22];
11521152
int fd;
11531153
bool restored = false;
11541154
int readBytes;

src/backend/storage/file/copydir.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ copydir(char *fromdir, char *todir, bool recurse)
3838
{
3939
DIR *xldir;
4040
struct dirent *xlde;
41-
char fromfile[MAXPGPATH];
42-
char tofile[MAXPGPATH];
41+
char fromfile[MAXPGPATH * 2];
42+
char tofile[MAXPGPATH * 2];
4343

4444
if (mkdir(todir, S_IRWXU) != 0)
4545
ereport(ERROR,
@@ -63,8 +63,8 @@ copydir(char *fromdir, char *todir, bool recurse)
6363
strcmp(xlde->d_name, "..") == 0)
6464
continue;
6565

66-
snprintf(fromfile, MAXPGPATH, "%s/%s", fromdir, xlde->d_name);
67-
snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
66+
snprintf(fromfile, sizeof(fromfile), "%s/%s", fromdir, xlde->d_name);
67+
snprintf(tofile, sizeof(tofile), "%s/%s", todir, xlde->d_name);
6868

6969
if (lstat(fromfile, &fst) < 0)
7070
ereport(ERROR,
@@ -103,7 +103,7 @@ copydir(char *fromdir, char *todir, bool recurse)
103103
strcmp(xlde->d_name, "..") == 0)
104104
continue;
105105

106-
snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
106+
snprintf(tofile, sizeof(tofile), "%s/%s", todir, xlde->d_name);
107107

108108
/*
109109
* We don't need to sync subdirectories here since the recursive

src/backend/storage/file/fd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,7 @@ CleanupTempFiles(bool isProcExit)
26542654
void
26552655
RemovePgTempFiles(void)
26562656
{
2657-
char temp_path[MAXPGPATH];
2657+
char temp_path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY) + sizeof(PG_TEMP_FILES_DIR)];
26582658
DIR *spc_dir;
26592659
struct dirent *spc_de;
26602660

@@ -2702,7 +2702,7 @@ RemovePgTempFilesInDir(const char *tmpdirname)
27022702
{
27032703
DIR *temp_dir;
27042704
struct dirent *temp_de;
2705-
char rm_path[MAXPGPATH];
2705+
char rm_path[MAXPGPATH * 2];
27062706

27072707
temp_dir = AllocateDir(tmpdirname);
27082708
if (temp_dir == NULL)
@@ -2743,7 +2743,7 @@ RemovePgTempRelationFiles(const char *tsdirname)
27432743
{
27442744
DIR *ts_dir;
27452745
struct dirent *de;
2746-
char dbspace_path[MAXPGPATH];
2746+
char dbspace_path[MAXPGPATH * 2];
27472747

27482748
ts_dir = AllocateDir(tsdirname);
27492749
if (ts_dir == NULL)
@@ -2784,7 +2784,7 @@ RemovePgTempRelationFilesInDbspace(const char *dbspacedirname)
27842784
{
27852785
DIR *dbspace_dir;
27862786
struct dirent *de;
2787-
char rm_path[MAXPGPATH];
2787+
char rm_path[MAXPGPATH * 2];
27882788

27892789
dbspace_dir = AllocateDir(dbspacedirname);
27902790
if (dbspace_dir == NULL)
@@ -2971,7 +2971,7 @@ walkdir(const char *path,
29712971

29722972
while ((de = ReadDirExtended(dir, path, elevel)) != NULL)
29732973
{
2974-
char subpath[MAXPGPATH];
2974+
char subpath[MAXPGPATH * 2];
29752975
struct stat fst;
29762976
int sret;
29772977

@@ -2981,7 +2981,7 @@ walkdir(const char *path,
29812981
strcmp(de->d_name, "..") == 0)
29822982
continue;
29832983

2984-
snprintf(subpath, MAXPGPATH, "%s/%s", path, de->d_name);
2984+
snprintf(subpath, sizeof(subpath), "%s/%s", path, de->d_name);
29852985

29862986
if (process_symlinks)
29872987
sret = stat(subpath, &fst);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy