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);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp