Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit47b4913

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 parent21c2c3d commit47b4913

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-
charWALFilePath[MAXPGPATH];/* the file path including archive */
60+
charWALFilePath[MAXPGPATH*2];/* the file path including archive */
6161
charrestoreCommand[MAXPGPATH];/* run this to restore */
6262
charexclusiveCleanupFileName[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
#ifdefWIN32
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
XLogRecPtrredo;
11951195
DIR*mappings_dir;
11961196
structdirent*mapping_de;
1197-
charpath[MAXPGPATH];
1197+
charpath[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
structdirent*xlde;
3944-
charpath[MAXPGPATH];
3944+
charpath[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-
charfullpath[MAXPGPATH];
10064+
charfullpath[MAXPGPATH+10];
1006510065
charlinkpath[MAXPGPATH];
1006610066
char*relpath=NULL;
1006710067
intrllen;

‎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
structdirent*entry;
572-
charfname[MAXPGPATH];
572+
charfname[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
structdirent*de;
891-
charpathbuf[MAXPGPATH];
891+
charpathbuf[MAXPGPATH*2];
892892
structstatstatbuf;
893893
int64size=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
structstatstatbuf;
2653-
charpath[MAXPGPATH];
2653+
charpath[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
XLogRecPtrredo;
18321832
DIR*snap_dir;
18331833
structdirent*snap_de;
1834-
charpath[MAXPGPATH];
1834+
charpath[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
structstatstatbuf;
921-
charpath[MAXPGPATH];
921+
charpath[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
ReplicationSlotOnDiskcp;
11501150
inti;
1151-
charpath[MAXPGPATH];
1151+
charpath[MAXPGPATH+22];
11521152
intfd;
11531153
boolrestored= false;
11541154
intreadBytes;

‎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
structdirent*xlde;
41-
charfromfile[MAXPGPATH];
42-
chartofile[MAXPGPATH];
41+
charfromfile[MAXPGPATH*2];
42+
chartofile[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-
chartemp_path[MAXPGPATH];
2657+
chartemp_path[MAXPGPATH+10+sizeof(TABLESPACE_VERSION_DIRECTORY)+sizeof(PG_TEMP_FILES_DIR)];
26582658
DIR*spc_dir;
26592659
structdirent*spc_de;
26602660

@@ -2702,7 +2702,7 @@ RemovePgTempFilesInDir(const char *tmpdirname)
27022702
{
27032703
DIR*temp_dir;
27042704
structdirent*temp_de;
2705-
charrm_path[MAXPGPATH];
2705+
charrm_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
structdirent*de;
2746-
chardbspace_path[MAXPGPATH];
2746+
chardbspace_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
structdirent*de;
2787-
charrm_path[MAXPGPATH];
2787+
charrm_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-
charsubpath[MAXPGPATH];
2974+
charsubpath[MAXPGPATH*2];
29752975
structstatfst;
29762976
intsret;
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);

‎src/backend/storage/file/reinit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef struct
4848
void
4949
ResetUnloggedRelations(intop)
5050
{
51-
chartemp_path[MAXPGPATH];
51+
chartemp_path[MAXPGPATH+10+sizeof(TABLESPACE_VERSION_DIRECTORY)];
5252
DIR*spc_dir;
5353
structdirent*spc_de;
5454
MemoryContexttmpctx,
@@ -104,7 +104,7 @@ ResetUnloggedRelationsInTablespaceDir(const char *tsdirname, int op)
104104
{
105105
DIR*ts_dir;
106106
structdirent*de;
107-
chardbspace_path[MAXPGPATH];
107+
chardbspace_path[MAXPGPATH*2];
108108

109109
ts_dir=AllocateDir(tsdirname);
110110
if (ts_dir==NULL)
@@ -145,7 +145,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
145145
{
146146
DIR*dbspace_dir;
147147
structdirent*de;
148-
charrm_path[MAXPGPATH];
148+
charrm_path[MAXPGPATH*2];
149149

150150
/* Caller must specify at least one operation. */
151151
Assert((op& (UNLOGGED_RELATION_CLEANUP |UNLOGGED_RELATION_INIT))!=0);
@@ -308,7 +308,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
308308
ForkNumberforkNum;
309309
intoidchars;
310310
charoidbuf[OIDCHARS+1];
311-
charsrcpath[MAXPGPATH];
311+
charsrcpath[MAXPGPATH*2];
312312
chardstpath[MAXPGPATH];
313313

314314
/* Skip anything that doesn't look like a relation data file. */

‎src/backend/storage/ipc/dsm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,9 @@ dsm_cleanup_for_mmap(void)
306306
if (strncmp(dent->d_name,PG_DYNSHMEM_MMAP_FILE_PREFIX,
307307
strlen(PG_DYNSHMEM_MMAP_FILE_PREFIX))==0)
308308
{
309-
charbuf[MAXPGPATH];
309+
charbuf[MAXPGPATH+sizeof(PG_DYNSHMEM_DIR)];
310310

311-
snprintf(buf,MAXPGPATH,PG_DYNSHMEM_DIR"/%s",dent->d_name);
311+
snprintf(buf,sizeof(buf),PG_DYNSHMEM_DIR"/%s",dent->d_name);
312312

313313
elog(DEBUG2,"removing file \"%s\"",buf);
314314

‎src/backend/utils/adt/dbsize.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ db_dir_size(const char *path)
4141
int64dirsize=0;
4242
structdirent*direntry;
4343
DIR*dirdesc;
44-
charfilename[MAXPGPATH];
44+
charfilename[MAXPGPATH*2];
4545

4646
dirdesc=AllocateDir(path);
4747

@@ -58,7 +58,7 @@ db_dir_size(const char *path)
5858
strcmp(direntry->d_name,"..")==0)
5959
continue;
6060

61-
snprintf(filename,MAXPGPATH,"%s/%s",path,direntry->d_name);
61+
snprintf(filename,sizeof(filename),"%s/%s",path,direntry->d_name);
6262

6363
if (stat(filename,&fst)<0)
6464
{
@@ -86,7 +86,7 @@ calculate_database_size(Oid dbOid)
8686
DIR*dirdesc;
8787
structdirent*direntry;
8888
chardirpath[MAXPGPATH];
89-
charpathname[MAXPGPATH];
89+
charpathname[MAXPGPATH+12+sizeof(TABLESPACE_VERSION_DIRECTORY)];
9090
AclResultaclresult;
9191

9292
/* User must have connect privilege for target database */
@@ -98,7 +98,7 @@ calculate_database_size(Oid dbOid)
9898
/* Shared storage in pg_global is not counted */
9999

100100
/* Include pg_default storage */
101-
snprintf(pathname,MAXPGPATH,"base/%u",dbOid);
101+
snprintf(pathname,sizeof(pathname),"base/%u",dbOid);
102102
totalsize=db_dir_size(pathname);
103103

104104
/* Scan the non-default tablespaces */
@@ -118,7 +118,7 @@ calculate_database_size(Oid dbOid)
118118
strcmp(direntry->d_name,"..")==0)
119119
continue;
120120

121-
snprintf(pathname,MAXPGPATH,"pg_tblspc/%s/%s/%u",
121+
snprintf(pathname,sizeof(pathname),"pg_tblspc/%s/%s/%u",
122122
direntry->d_name,TABLESPACE_VERSION_DIRECTORY,dbOid);
123123
totalsize+=db_dir_size(pathname);
124124
}
@@ -166,7 +166,7 @@ static int64
166166
calculate_tablespace_size(OidtblspcOid)
167167
{
168168
chartblspcPath[MAXPGPATH];
169-
charpathname[MAXPGPATH];
169+
charpathname[MAXPGPATH*2];
170170
int64totalsize=0;
171171
DIR*dirdesc;
172172
structdirent*direntry;
@@ -208,7 +208,7 @@ calculate_tablespace_size(Oid tblspcOid)
208208
strcmp(direntry->d_name,"..")==0)
209209
continue;
210210

211-
snprintf(pathname,MAXPGPATH,"%s/%s",tblspcPath,direntry->d_name);
211+
snprintf(pathname,sizeof(pathname),"%s/%s",tblspcPath,direntry->d_name);
212212

213213
if (stat(pathname,&fst)<0)
214214
{

‎src/backend/utils/cache/relcache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5525,7 +5525,7 @@ RelationCacheInitFileRemove(void)
55255525
constchar*tblspcdir="pg_tblspc";
55265526
DIR*dir;
55275527
structdirent*de;
5528-
charpath[MAXPGPATH];
5528+
charpath[MAXPGPATH+10+sizeof(TABLESPACE_VERSION_DIRECTORY)];
55295529

55305530
/*
55315531
* We zap the shared cache file too. In theory it can't get out of sync
@@ -5567,7 +5567,7 @@ RelationCacheInitFileRemoveInDir(const char *tblspcpath)
55675567
{
55685568
DIR*dir;
55695569
structdirent*de;
5570-
charinitfilename[MAXPGPATH];
5570+
charinitfilename[MAXPGPATH*2];
55715571

55725572
/* Scan the tablespace directory to find per-database directories */
55735573
dir=AllocateDir(tblspcpath);

‎src/backend/utils/error/elog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ static void
22282228
setup_formatted_log_time(void)
22292229
{
22302230
pg_time_tstamp_time;
2231-
charmsbuf[8];
2231+
charmsbuf[13];
22322232

22332233
if (!saved_timeval_set)
22342234
{

‎src/backend/utils/time/snapmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ XactHasExportedSnapshots(void)
15691569
void
15701570
DeleteAllExportedSnapshotFiles(void)
15711571
{
1572-
charbuf[MAXPGPATH];
1572+
charbuf[MAXPGPATH+sizeof(SNAPSHOT_EXPORT_DIR)];
15731573
DIR*s_dir;
15741574
structdirent*s_de;
15751575

@@ -1590,7 +1590,7 @@ DeleteAllExportedSnapshotFiles(void)
15901590
strcmp(s_de->d_name,"..")==0)
15911591
continue;
15921592

1593-
snprintf(buf,MAXPGPATH,SNAPSHOT_EXPORT_DIR"/%s",s_de->d_name);
1593+
snprintf(buf,sizeof(buf),SNAPSHOT_EXPORT_DIR"/%s",s_de->d_name);
15941594
/* Again, unlink failure is not worthy of FATAL */
15951595
if (unlink(buf))
15961596
elog(LOG,"could not unlink file \"%s\": %m",buf);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp