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

Commit6275f5d

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 parent0e8286d commit6275f5d

File tree

23 files changed

+68
-68
lines changed

23 files changed

+68
-68
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
@@ -1203,7 +1203,7 @@ CheckPointLogicalRewriteHeap(void)
12031203
XLogRecPtrredo;
12041204
DIR*mappings_dir;
12051205
structdirent*mapping_de;
1206-
charpath[MAXPGPATH];
1206+
charpath[MAXPGPATH+20];
12071207

12081208
/*
12091209
* We start of with a minimum of the last redo pointer. No new decoding
@@ -1234,7 +1234,7 @@ CheckPointLogicalRewriteHeap(void)
12341234
strcmp(mapping_de->d_name,"..")==0)
12351235
continue;
12361236

1237-
snprintf(path,MAXPGPATH,"pg_logical/mappings/%s",mapping_de->d_name);
1237+
snprintf(path,sizeof(path),"pg_logical/mappings/%s",mapping_de->d_name);
12381238
if (lstat(path,&statbuf)==0&& !S_ISREG(statbuf.st_mode))
12391239
continue;
12401240

‎src/backend/access/transam/xlog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4102,7 +4102,7 @@ CleanupBackupHistory(void)
41024102
{
41034103
DIR*xldir;
41044104
structdirent*xlde;
4105-
charpath[MAXPGPATH];
4105+
charpath[MAXPGPATH+sizeof(XLOGDIR)];
41064106

41074107
xldir=AllocateDir(XLOGDIR);
41084108
if (xldir==NULL)
@@ -4120,7 +4120,7 @@ CleanupBackupHistory(void)
41204120
ereport(DEBUG2,
41214121
(errmsg("removing transaction log backup history file \"%s\"",
41224122
xlde->d_name)));
4123-
snprintf(path,MAXPGPATH,XLOGDIR"/%s",xlde->d_name);
4123+
snprintf(path,sizeof(path),XLOGDIR"/%s",xlde->d_name);
41244124
unlink(path);
41254125
XLogArchiveCleanup(xlde->d_name);
41264126
}
@@ -10389,7 +10389,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
1038910389
/* Collect information about all tablespaces */
1039010390
while ((de=ReadDir(tblspcdir,"pg_tblspc"))!=NULL)
1039110391
{
10392-
charfullpath[MAXPGPATH];
10392+
charfullpath[MAXPGPATH+10];
1039310393
charlinkpath[MAXPGPATH];
1039410394
char*relpath=NULL;
1039510395
intrllen;

‎src/backend/postmaster/pgstat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ pgstat_reset_remove_files(const char *directory)
606606
{
607607
DIR*dir;
608608
structdirent*entry;
609-
charfname[MAXPGPATH];
609+
charfname[MAXPGPATH*2];
610610

611611
dir=AllocateDir(directory);
612612
while ((entry=ReadDir(dir,directory))!=NULL)
@@ -636,7 +636,7 @@ pgstat_reset_remove_files(const char *directory)
636636
strcmp(entry->d_name+nchars,"stat")!=0)
637637
continue;
638638

639-
snprintf(fname,MAXPGPATH,"%s/%s",directory,
639+
snprintf(fname,sizeof(fname),"%s/%s",directory,
640640
entry->d_name);
641641
unlink(fname);
642642
}

‎src/backend/replication/basebackup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces,
959959
{
960960
DIR*dir;
961961
structdirent*de;
962-
charpathbuf[MAXPGPATH];
962+
charpathbuf[MAXPGPATH*2];
963963
structstatstatbuf;
964964
int64size=0;
965965

@@ -1011,7 +1011,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces,
10111011
if (excludeFound)
10121012
continue;
10131013

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

10161016
/* Skip pg_control here to back up it last */
10171017
if (strcmp(pathbuf,"./global/pg_control")==0)

‎src/backend/replication/logical/reorderbuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2613,7 +2613,7 @@ StartupReorderBuffer(void)
26132613
while ((logical_de=ReadDir(logical_dir,"pg_replslot"))!=NULL)
26142614
{
26152615
structstatstatbuf;
2616-
charpath[MAXPGPATH];
2616+
charpath[MAXPGPATH*2+12];
26172617

26182618
if (strcmp(logical_de->d_name,".")==0||
26192619
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
@@ -1868,7 +1868,7 @@ CheckPointSnapBuild(void)
18681868
XLogRecPtrredo;
18691869
DIR*snap_dir;
18701870
structdirent*snap_de;
1871-
charpath[MAXPGPATH];
1871+
charpath[MAXPGPATH+21];
18721872

18731873
/*
18741874
* We start off with a minimum of the last redo pointer. No new replication
@@ -1895,7 +1895,7 @@ CheckPointSnapBuild(void)
18951895
strcmp(snap_de->d_name,"..")==0)
18961896
continue;
18971897

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

19001900
if (lstat(path,&statbuf)==0&& !S_ISREG(statbuf.st_mode))
19011901
{

‎src/backend/replication/slot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,13 +1023,13 @@ StartupReplicationSlots(void)
10231023
while ((replication_de=ReadDir(replication_dir,"pg_replslot"))!=NULL)
10241024
{
10251025
structstatstatbuf;
1026-
charpath[MAXPGPATH];
1026+
charpath[MAXPGPATH+12];
10271027

10281028
if (strcmp(replication_de->d_name,".")==0||
10291029
strcmp(replication_de->d_name,"..")==0)
10301030
continue;
10311031

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

10341034
/* we're only creating directories here, skip if it's not our's */
10351035
if (lstat(path,&statbuf)==0&& !S_ISDIR(statbuf.st_mode))
@@ -1259,7 +1259,7 @@ RestoreSlotFromDisk(const char *name)
12591259
{
12601260
ReplicationSlotOnDiskcp;
12611261
inti;
1262-
charpath[MAXPGPATH];
1262+
charpath[MAXPGPATH+22];
12631263
intfd;
12641264
boolrestored= false;
12651265
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
@@ -2705,7 +2705,7 @@ CleanupTempFiles(bool isProcExit)
27052705
void
27062706
RemovePgTempFiles(void)
27072707
{
2708-
chartemp_path[MAXPGPATH];
2708+
chartemp_path[MAXPGPATH+10+sizeof(TABLESPACE_VERSION_DIRECTORY)+sizeof(PG_TEMP_FILES_DIR)];
27092709
DIR*spc_dir;
27102710
structdirent*spc_de;
27112711

@@ -2753,7 +2753,7 @@ RemovePgTempFilesInDir(const char *tmpdirname)
27532753
{
27542754
DIR*temp_dir;
27552755
structdirent*temp_de;
2756-
charrm_path[MAXPGPATH];
2756+
charrm_path[MAXPGPATH*2];
27572757

27582758
temp_dir=AllocateDir(tmpdirname);
27592759
if (temp_dir==NULL)
@@ -2794,7 +2794,7 @@ RemovePgTempRelationFiles(const char *tsdirname)
27942794
{
27952795
DIR*ts_dir;
27962796
structdirent*de;
2797-
chardbspace_path[MAXPGPATH];
2797+
chardbspace_path[MAXPGPATH*2];
27982798

27992799
ts_dir=AllocateDir(tsdirname);
28002800
if (ts_dir==NULL)
@@ -2835,7 +2835,7 @@ RemovePgTempRelationFilesInDbspace(const char *dbspacedirname)
28352835
{
28362836
DIR*dbspace_dir;
28372837
structdirent*de;
2838-
charrm_path[MAXPGPATH];
2838+
charrm_path[MAXPGPATH*2];
28392839

28402840
dbspace_dir=AllocateDir(dbspacedirname);
28412841
if (dbspace_dir==NULL)
@@ -3022,7 +3022,7 @@ walkdir(const char *path,
30223022

30233023
while ((de=ReadDirExtended(dir,path,elevel))!=NULL)
30243024
{
3025-
charsubpath[MAXPGPATH];
3025+
charsubpath[MAXPGPATH*2];
30263026
structstatfst;
30273027
intsret;
30283028

@@ -3032,7 +3032,7 @@ walkdir(const char *path,
30323032
strcmp(de->d_name,"..")==0)
30333033
continue;
30343034

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

30373037
if (process_symlinks)
30383038
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
@@ -307,9 +307,9 @@ dsm_cleanup_for_mmap(void)
307307
if (strncmp(dent->d_name,PG_DYNSHMEM_MMAP_FILE_PREFIX,
308308
strlen(PG_DYNSHMEM_MMAP_FILE_PREFIX))==0)
309309
{
310-
charbuf[MAXPGPATH];
310+
charbuf[MAXPGPATH+sizeof(PG_DYNSHMEM_DIR)];
311311

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

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

‎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
/*
@@ -104,7 +104,7 @@ calculate_database_size(Oid dbOid)
104104
/* Shared storage in pg_global is not counted */
105105

106106
/* Include pg_default storage */
107-
snprintf(pathname,MAXPGPATH,"base/%u",dbOid);
107+
snprintf(pathname,sizeof(pathname),"base/%u",dbOid);
108108
totalsize=db_dir_size(pathname);
109109

110110
/* Scan the non-default tablespaces */
@@ -124,7 +124,7 @@ calculate_database_size(Oid dbOid)
124124
strcmp(direntry->d_name,"..")==0)
125125
continue;
126126

127-
snprintf(pathname,MAXPGPATH,"pg_tblspc/%s/%s/%u",
127+
snprintf(pathname,sizeof(pathname),"pg_tblspc/%s/%s/%u",
128128
direntry->d_name,TABLESPACE_VERSION_DIRECTORY,dbOid);
129129
totalsize+=db_dir_size(pathname);
130130
}
@@ -172,7 +172,7 @@ static int64
172172
calculate_tablespace_size(OidtblspcOid)
173173
{
174174
chartblspcPath[MAXPGPATH];
175-
charpathname[MAXPGPATH];
175+
charpathname[MAXPGPATH*2];
176176
int64totalsize=0;
177177
DIR*dirdesc;
178178
structdirent*direntry;
@@ -215,7 +215,7 @@ calculate_tablespace_size(Oid tblspcOid)
215215
strcmp(direntry->d_name,"..")==0)
216216
continue;
217217

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

220220
if (stat(pathname,&fst)<0)
221221
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, char *dir)
522522
{
523523
Datumvalues[3];
524524
boolnulls[3];
525-
charpath[MAXPGPATH];
525+
charpath[MAXPGPATH*2];
526526
structstatattrib;
527527
HeapTupletuple;
528528

@@ -531,7 +531,7 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, char *dir)
531531
continue;
532532

533533
/* Get the file info */
534-
snprintf(path,MAXPGPATH,"%s/%s",fctx->location,de->d_name);
534+
snprintf(path,sizeof(path),"%s/%s",fctx->location,de->d_name);
535535
if (stat(path,&attrib)<0)
536536
ereport(ERROR,
537537
(errcode_for_file_access(),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6074,7 +6074,7 @@ RelationCacheInitFileRemove(void)
60746074
constchar*tblspcdir="pg_tblspc";
60756075
DIR*dir;
60766076
structdirent*de;
6077-
charpath[MAXPGPATH];
6077+
charpath[MAXPGPATH+10+sizeof(TABLESPACE_VERSION_DIRECTORY)];
60786078

60796079
/*
60806080
* We zap the shared cache file too. In theory it can't get out of sync
@@ -6116,7 +6116,7 @@ RelationCacheInitFileRemoveInDir(const char *tblspcpath)
61166116
{
61176117
DIR*dir;
61186118
structdirent*de;
6119-
charinitfilename[MAXPGPATH];
6119+
charinitfilename[MAXPGPATH*2];
61206120

61216121
/* Scan the tablespace directory to find per-database directories */
61226122
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
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp