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

Commit80a06b5

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 parent2c80c37 commit80a06b5

File tree

17 files changed

+52
-52
lines changed

17 files changed

+52
-52
lines changed

‎contrib/pg_archivecleanup/pg_archivecleanup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ char *additional_ext = NULL;/* Extension to remove from filenames */
4141

4242
char*archiveLocation;/* where to find the archive? */
4343
char*restartWALFileName;/* the file from which we can restart restore */
44-
charWALFilePath[MAXPGPATH];/* the file path including archive */
44+
charWALFilePath[MAXPGPATH*2];/* the file path including archive */
4545
charexclusiveCleanupFileName[MAXPGPATH];/* the oldest file we
4646
* want to remain in
4747
* archive */
@@ -144,7 +144,7 @@ CleanupPriorWALFiles(void)
144144
* extension that might have been chopped off before testing
145145
* the sequence.
146146
*/
147-
snprintf(WALFilePath,MAXPGPATH,"%s/%s",
147+
snprintf(WALFilePath,sizeof(WALFilePath),"%s/%s",
148148
archiveLocation,xlde->d_name);
149149

150150
if (dryrun)

‎contrib/pg_standby/pg_standby.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ char *xlogFilePath;/* where we are going to restore to */
6666
char*nextWALFileName;/* the file we need to get from archive */
6767
char*restartWALFileName;/* the file from which we can restart restore */
6868
char*priorWALFileName;/* the file we need to get from archive */
69-
charWALFilePath[MAXPGPATH];/* the file path including archive */
69+
charWALFilePath[MAXPGPATH*2];/* the file path including archive */
7070
charrestoreCommand[MAXPGPATH];/* run this to restore */
7171
charexclusiveCleanupFileName[MAXPGPATH];/* the file we need to
7272
* get from archive */
@@ -277,9 +277,9 @@ CustomizableCleanupPriorWALFiles(void)
277277
strcmp(xlde->d_name+8,exclusiveCleanupFileName+8)<0)
278278
{
279279
#ifdefWIN32
280-
snprintf(WALFilePath,MAXPGPATH,"%s\\%s",archiveLocation,xlde->d_name);
280+
snprintf(WALFilePath,sizeof(WALFilePath),"%s\\%s",archiveLocation,xlde->d_name);
281281
#else
282-
snprintf(WALFilePath,MAXPGPATH,"%s/%s",archiveLocation,xlde->d_name);
282+
snprintf(WALFilePath,sizeof(WALFilePath),"%s/%s",archiveLocation,xlde->d_name);
283283
#endif
284284

285285
if (debug)

‎contrib/pg_upgrade/relfilenode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ transfer_relfile(pageCnvCtx *pageConverter, FileNameMap *map,
215215
constchar*type_suffix)
216216
{
217217
constchar*msg;
218-
charold_file[MAXPGPATH];
219-
charnew_file[MAXPGPATH];
218+
charold_file[MAXPGPATH*3];
219+
charnew_file[MAXPGPATH*3];
220220
intfd;
221221
intsegno;
222222
charextent_suffix[65];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,7 +3099,7 @@ CleanupBackupHistory(void)
30993099
{
31003100
DIR*xldir;
31013101
structdirent*xlde;
3102-
charpath[MAXPGPATH];
3102+
charpath[MAXPGPATH+sizeof(XLOGDIR)];
31033103

31043104
xldir=AllocateDir(XLOGDIR);
31053105
if (xldir==NULL)
@@ -3120,7 +3120,7 @@ CleanupBackupHistory(void)
31203120
ereport(DEBUG2,
31213121
(errmsg("removing transaction log backup history file \"%s\"",
31223122
xlde->d_name)));
3123-
snprintf(path,MAXPGPATH,XLOGDIR"/%s",xlde->d_name);
3123+
snprintf(path,sizeof(path),XLOGDIR"/%s",xlde->d_name);
31243124
unlink(path);
31253125
XLogArchiveCleanup(xlde->d_name);
31263126
}

‎src/backend/postmaster/pgstat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ pgstat_reset_remove_files(const char *directory)
559559
{
560560
DIR*dir;
561561
structdirent*entry;
562-
charfname[MAXPGPATH];
562+
charfname[MAXPGPATH*2];
563563

564564
dir=AllocateDir(directory);
565565
while ((entry=ReadDir(dir,directory))!=NULL)
@@ -589,7 +589,7 @@ pgstat_reset_remove_files(const char *directory)
589589
strcmp(entry->d_name+nchars,"stat")!=0)
590590
continue;
591591

592-
snprintf(fname,MAXPGPATH,"%s/%s",directory,
592+
snprintf(fname,sizeof(fname),"%s/%s",directory,
593593
entry->d_name);
594594
unlink(fname);
595595
}

‎src/backend/replication/basebackup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
122122
/* Collect information about all tablespaces */
123123
while ((de=ReadDir(tblspcdir,"pg_tblspc"))!=NULL)
124124
{
125-
charfullpath[MAXPGPATH];
125+
charfullpath[MAXPGPATH+10];
126126
charlinkpath[MAXPGPATH];
127127
char*relpath=NULL;
128128
intrllen;
@@ -831,7 +831,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces)
831831
{
832832
DIR*dir;
833833
structdirent*de;
834-
charpathbuf[MAXPGPATH];
834+
charpathbuf[MAXPGPATH*2];
835835
structstatstatbuf;
836836
int64size=0;
837837

@@ -873,7 +873,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces)
873873
"and should not be used. "
874874
"Try taking another online backup.")));
875875

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

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

‎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
@@ -2460,7 +2460,7 @@ CleanupTempFiles(bool isProcExit)
24602460
void
24612461
RemovePgTempFiles(void)
24622462
{
2463-
chartemp_path[MAXPGPATH];
2463+
chartemp_path[MAXPGPATH+10+sizeof(TABLESPACE_VERSION_DIRECTORY)+sizeof(PG_TEMP_FILES_DIR)];
24642464
DIR*spc_dir;
24652465
structdirent*spc_de;
24662466

@@ -2508,7 +2508,7 @@ RemovePgTempFilesInDir(const char *tmpdirname)
25082508
{
25092509
DIR*temp_dir;
25102510
structdirent*temp_de;
2511-
charrm_path[MAXPGPATH];
2511+
charrm_path[MAXPGPATH*2];
25122512

25132513
temp_dir=AllocateDir(tmpdirname);
25142514
if (temp_dir==NULL)
@@ -2549,7 +2549,7 @@ RemovePgTempRelationFiles(const char *tsdirname)
25492549
{
25502550
DIR*ts_dir;
25512551
structdirent*de;
2552-
chardbspace_path[MAXPGPATH];
2552+
chardbspace_path[MAXPGPATH*2];
25532553

25542554
ts_dir=AllocateDir(tsdirname);
25552555
if (ts_dir==NULL)
@@ -2590,7 +2590,7 @@ RemovePgTempRelationFilesInDbspace(const char *dbspacedirname)
25902590
{
25912591
DIR*dbspace_dir;
25922592
structdirent*de;
2593-
charrm_path[MAXPGPATH];
2593+
charrm_path[MAXPGPATH*2];
25942594

25952595
dbspace_dir=AllocateDir(dbspacedirname);
25962596
if (dbspace_dir==NULL)
@@ -2777,7 +2777,7 @@ walkdir(const char *path,
27772777

27782778
while ((de=ReadDirExtended(dir,path,elevel))!=NULL)
27792779
{
2780-
charsubpath[MAXPGPATH];
2780+
charsubpath[MAXPGPATH*2];
27812781
structstatfst;
27822782
intsret;
27832783

@@ -2787,7 +2787,7 @@ walkdir(const char *path,
27872787
strcmp(de->d_name,"..")==0)
27882788
continue;
27892789

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

27922792
if (process_symlinks)
27932793
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,
@@ -106,7 +106,7 @@ ResetUnloggedRelationsInTablespaceDir(const char *tsdirname, int op)
106106
{
107107
DIR*ts_dir;
108108
structdirent*de;
109-
chardbspace_path[MAXPGPATH];
109+
chardbspace_path[MAXPGPATH*2];
110110

111111
ts_dir=AllocateDir(tsdirname);
112112
if (ts_dir==NULL)
@@ -147,7 +147,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
147147
{
148148
DIR*dbspace_dir;
149149
structdirent*de;
150-
charrm_path[MAXPGPATH];
150+
charrm_path[MAXPGPATH*2];
151151

152152
/* Caller must specify at least one operation. */
153153
Assert((op& (UNLOGGED_RELATION_CLEANUP |UNLOGGED_RELATION_INIT))!=0);
@@ -310,7 +310,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
310310
ForkNumberforkNum;
311311
intoidchars;
312312
charoidbuf[OIDCHARS+1];
313-
charsrcpath[MAXPGPATH];
313+
charsrcpath[MAXPGPATH*2];
314314
chardstpath[MAXPGPATH];
315315

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

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

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

4444
dirdesc=AllocateDir(path);
4545

@@ -56,7 +56,7 @@ db_dir_size(const char *path)
5656
strcmp(direntry->d_name,"..")==0)
5757
continue;
5858

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

6161
if (stat(filename,&fst)<0)
6262
{
@@ -84,7 +84,7 @@ calculate_database_size(Oid dbOid)
8484
DIR*dirdesc;
8585
structdirent*direntry;
8686
chardirpath[MAXPGPATH];
87-
charpathname[MAXPGPATH];
87+
charpathname[MAXPGPATH+12+sizeof(TABLESPACE_VERSION_DIRECTORY)];
8888
AclResultaclresult;
8989

9090
/* User must have connect privilege for target database */
@@ -96,7 +96,7 @@ calculate_database_size(Oid dbOid)
9696
/* Shared storage in pg_global is not counted */
9797

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

102102
/* Scan the non-default tablespaces */
@@ -116,7 +116,7 @@ calculate_database_size(Oid dbOid)
116116
strcmp(direntry->d_name,"..")==0)
117117
continue;
118118

119-
snprintf(pathname,MAXPGPATH,"pg_tblspc/%s/%s/%u",
119+
snprintf(pathname,sizeof(pathname),"pg_tblspc/%s/%s/%u",
120120
direntry->d_name,TABLESPACE_VERSION_DIRECTORY,dbOid);
121121
totalsize+=db_dir_size(pathname);
122122
}
@@ -164,7 +164,7 @@ static int64
164164
calculate_tablespace_size(OidtblspcOid)
165165
{
166166
chartblspcPath[MAXPGPATH];
167-
charpathname[MAXPGPATH];
167+
charpathname[MAXPGPATH*2];
168168
int64totalsize=0;
169169
DIR*dirdesc;
170170
structdirent*direntry;
@@ -206,7 +206,7 @@ calculate_tablespace_size(Oid tblspcOid)
206206
strcmp(direntry->d_name,"..")==0)
207207
continue;
208208

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

211211
if (stat(pathname,&fst)<0)
212212
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4869,7 +4869,7 @@ RelationCacheInitFileRemove(void)
48694869
constchar*tblspcdir="pg_tblspc";
48704870
DIR*dir;
48714871
structdirent*de;
4872-
charpath[MAXPGPATH];
4872+
charpath[MAXPGPATH+10+sizeof(TABLESPACE_VERSION_DIRECTORY)];
48734873

48744874
/*
48754875
* We zap the shared cache file too. In theory it can't get out of sync
@@ -4911,7 +4911,7 @@ RelationCacheInitFileRemoveInDir(const char *tblspcpath)
49114911
{
49124912
DIR*dir;
49134913
structdirent*de;
4914-
charinitfilename[MAXPGPATH];
4914+
charinitfilename[MAXPGPATH*2];
49154915

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ setup_formatted_log_time(void)
20132013
{
20142014
structtimevaltv;
20152015
pg_time_tstamp_time;
2016-
charmsbuf[8];
2016+
charmsbuf[13];
20172017

20182018
gettimeofday(&tv,NULL);
20192019
stamp_time= (pg_time_t)tv.tv_sec;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ XactHasExportedSnapshots(void)
11551155
void
11561156
DeleteAllExportedSnapshotFiles(void)
11571157
{
1158-
charbuf[MAXPGPATH];
1158+
charbuf[MAXPGPATH+sizeof(SNAPSHOT_EXPORT_DIR)];
11591159
DIR*s_dir;
11601160
structdirent*s_de;
11611161

@@ -1176,7 +1176,7 @@ DeleteAllExportedSnapshotFiles(void)
11761176
strcmp(s_de->d_name,"..")==0)
11771177
continue;
11781178

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

‎src/bin/initdb/initdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,15 +556,15 @@ walkdir(const char *path,
556556

557557
while (errno=0, (de=readdir(dir))!=NULL)
558558
{
559-
charsubpath[MAXPGPATH];
559+
charsubpath[MAXPGPATH*2];
560560
structstatfst;
561561
intsret;
562562

563563
if (strcmp(de->d_name,".")==0||
564564
strcmp(de->d_name,"..")==0)
565565
continue;
566566

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

569569
if (process_symlinks)
570570
sret=stat(subpath,&fst);

‎src/bin/pg_basebackup/pg_receivexlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ FindStreamingStart(uint32 *tli)
178178
if (!ispartial)
179179
{
180180
structstatstatbuf;
181-
charfullpath[MAXPGPATH];
181+
charfullpath[MAXPGPATH*2];
182182

183183
snprintf(fullpath,sizeof(fullpath),"%s/%s",basedir,dirent->d_name);
184184
if (stat(fullpath,&statbuf)!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp