mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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.
This commit is contained in:
@@ -38,8 +38,8 @@ copydir(char *fromdir, char *todir, bool recurse)
|
||||
{
|
||||
DIR *xldir;
|
||||
struct dirent *xlde;
|
||||
char fromfile[MAXPGPATH];
|
||||
char tofile[MAXPGPATH];
|
||||
char fromfile[MAXPGPATH * 2];
|
||||
char tofile[MAXPGPATH * 2];
|
||||
|
||||
if (mkdir(todir, S_IRWXU) != 0)
|
||||
ereport(ERROR,
|
||||
@@ -63,8 +63,8 @@ copydir(char *fromdir, char *todir, bool recurse)
|
||||
strcmp(xlde->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
snprintf(fromfile, MAXPGPATH, "%s/%s", fromdir, xlde->d_name);
|
||||
snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
|
||||
snprintf(fromfile, sizeof(fromfile), "%s/%s", fromdir, xlde->d_name);
|
||||
snprintf(tofile, sizeof(tofile), "%s/%s", todir, xlde->d_name);
|
||||
|
||||
if (lstat(fromfile, &fst) < 0)
|
||||
ereport(ERROR,
|
||||
@@ -103,7 +103,7 @@ copydir(char *fromdir, char *todir, bool recurse)
|
||||
strcmp(xlde->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
|
||||
snprintf(tofile, sizeof(tofile), "%s/%s", todir, xlde->d_name);
|
||||
|
||||
/*
|
||||
* We don't need to sync subdirectories here since the recursive
|
||||
|
@@ -2454,7 +2454,7 @@ CleanupTempFiles(bool isProcExit)
|
||||
void
|
||||
RemovePgTempFiles(void)
|
||||
{
|
||||
char temp_path[MAXPGPATH];
|
||||
char temp_path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY) + sizeof(PG_TEMP_FILES_DIR)];
|
||||
DIR *spc_dir;
|
||||
struct dirent *spc_de;
|
||||
|
||||
@@ -2502,7 +2502,7 @@ RemovePgTempFilesInDir(const char *tmpdirname)
|
||||
{
|
||||
DIR *temp_dir;
|
||||
struct dirent *temp_de;
|
||||
char rm_path[MAXPGPATH];
|
||||
char rm_path[MAXPGPATH * 2];
|
||||
|
||||
temp_dir = AllocateDir(tmpdirname);
|
||||
if (temp_dir == NULL)
|
||||
@@ -2543,7 +2543,7 @@ RemovePgTempRelationFiles(const char *tsdirname)
|
||||
{
|
||||
DIR *ts_dir;
|
||||
struct dirent *de;
|
||||
char dbspace_path[MAXPGPATH];
|
||||
char dbspace_path[MAXPGPATH * 2];
|
||||
|
||||
ts_dir = AllocateDir(tsdirname);
|
||||
if (ts_dir == NULL)
|
||||
@@ -2584,7 +2584,7 @@ RemovePgTempRelationFilesInDbspace(const char *dbspacedirname)
|
||||
{
|
||||
DIR *dbspace_dir;
|
||||
struct dirent *de;
|
||||
char rm_path[MAXPGPATH];
|
||||
char rm_path[MAXPGPATH * 2];
|
||||
|
||||
dbspace_dir = AllocateDir(dbspacedirname);
|
||||
if (dbspace_dir == NULL)
|
||||
@@ -2771,7 +2771,7 @@ walkdir(const char *path,
|
||||
|
||||
while ((de = ReadDirExtended(dir, path, elevel)) != NULL)
|
||||
{
|
||||
char subpath[MAXPGPATH];
|
||||
char subpath[MAXPGPATH * 2];
|
||||
struct stat fst;
|
||||
int sret;
|
||||
|
||||
@@ -2781,7 +2781,7 @@ walkdir(const char *path,
|
||||
strcmp(de->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
snprintf(subpath, MAXPGPATH, "%s/%s", path, de->d_name);
|
||||
snprintf(subpath, sizeof(subpath), "%s/%s", path, de->d_name);
|
||||
|
||||
if (process_symlinks)
|
||||
sret = stat(subpath, &fst);
|
||||
|
@@ -48,7 +48,7 @@ typedef struct
|
||||
void
|
||||
ResetUnloggedRelations(int op)
|
||||
{
|
||||
char temp_path[MAXPGPATH];
|
||||
char temp_path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY)];
|
||||
DIR *spc_dir;
|
||||
struct dirent *spc_de;
|
||||
MemoryContext tmpctx,
|
||||
@@ -106,7 +106,7 @@ ResetUnloggedRelationsInTablespaceDir(const char *tsdirname, int op)
|
||||
{
|
||||
DIR *ts_dir;
|
||||
struct dirent *de;
|
||||
char dbspace_path[MAXPGPATH];
|
||||
char dbspace_path[MAXPGPATH * 2];
|
||||
|
||||
ts_dir = AllocateDir(tsdirname);
|
||||
if (ts_dir == NULL)
|
||||
@@ -147,7 +147,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
|
||||
{
|
||||
DIR *dbspace_dir;
|
||||
struct dirent *de;
|
||||
char rm_path[MAXPGPATH];
|
||||
char rm_path[MAXPGPATH * 2];
|
||||
|
||||
/* Caller must specify at least one operation. */
|
||||
Assert((op & (UNLOGGED_RELATION_CLEANUP | UNLOGGED_RELATION_INIT)) != 0);
|
||||
@@ -310,7 +310,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
|
||||
ForkNumber forkNum;
|
||||
int oidchars;
|
||||
char oidbuf[OIDCHARS + 1];
|
||||
char srcpath[MAXPGPATH];
|
||||
char srcpath[MAXPGPATH * 2];
|
||||
char dstpath[MAXPGPATH];
|
||||
|
||||
/* Skip anything that doesn't look like a relation data file. */
|
||||
|
@@ -306,9 +306,9 @@ dsm_cleanup_for_mmap(void)
|
||||
if (strncmp(dent->d_name, PG_DYNSHMEM_MMAP_FILE_PREFIX,
|
||||
strlen(PG_DYNSHMEM_MMAP_FILE_PREFIX)) == 0)
|
||||
{
|
||||
char buf[MAXPGPATH];
|
||||
char buf[MAXPGPATH + sizeof(PG_DYNSHMEM_DIR)];
|
||||
|
||||
snprintf(buf, MAXPGPATH, PG_DYNSHMEM_DIR "/%s", dent->d_name);
|
||||
snprintf(buf, sizeof(buf), PG_DYNSHMEM_DIR "/%s", dent->d_name);
|
||||
|
||||
elog(DEBUG2, "removing file \"%s\"", buf);
|
||||
|
||||
|
Reference in New Issue
Block a user