Skip to content

Commit c005eb0

Browse files
committed
Standardize the printf format for st_size
Existing code used various inconsistent ways to printf struct stat's st_size member. The type of that is off_t, which is in most cases a signed 64-bit integer, so use the long long int format for it.
1 parent aecf5ee commit c005eb0

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

src/backend/access/transam/twophase.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,10 +1243,10 @@ ReadTwoPhaseFile(TransactionId xid, bool missing_ok)
12431243
stat.st_size > MaxAllocSize)
12441244
ereport(ERROR,
12451245
(errcode(ERRCODE_DATA_CORRUPTED),
1246-
errmsg_plural("incorrect size of file \"%s\": %zu byte",
1247-
"incorrect size of file \"%s\": %zu bytes",
1248-
(Size) stat.st_size, path,
1249-
(Size) stat.st_size)));
1246+
errmsg_plural("incorrect size of file \"%s\": %lld byte",
1247+
"incorrect size of file \"%s\": %lld bytes",
1248+
(long long int) stat.st_size, path,
1249+
(long long int) stat.st_size)));
12501250

12511251
crc_offset = stat.st_size - sizeof(pg_crc32c);
12521252
if (crc_offset != MAXALIGN(crc_offset))
@@ -1270,8 +1270,8 @@ ReadTwoPhaseFile(TransactionId xid, bool missing_ok)
12701270
errmsg("could not read file \"%s\": %m", path)));
12711271
else
12721272
ereport(ERROR,
1273-
(errmsg("could not read file \"%s\": read %d of %zu",
1274-
path, r, (Size) stat.st_size)));
1273+
(errmsg("could not read file \"%s\": read %d of %lld",
1274+
path, r, (long long int) stat.st_size)));
12751275
}
12761276

12771277
pgstat_report_wait_end();

src/backend/access/transam/xlogarchive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ RestoreArchivedFile(char *path, const char *xlogfname,
202202
else
203203
elevel = FATAL;
204204
ereport(elevel,
205-
(errmsg("archive file \"%s\" has wrong size: %lu instead of %lu",
205+
(errmsg("archive file \"%s\" has wrong size: %lld instead of %lld",
206206
xlogfname,
207-
(unsigned long) stat_buf.st_size,
208-
(unsigned long) expectedSize)));
207+
(long long int) stat_buf.st_size,
208+
(long long int) expectedSize)));
209209
return false;
210210
}
211211
else

src/bin/pg_basebackup/pg_receivewal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ FindStreamingStart(uint32 *tli)
269269

270270
if (statbuf.st_size != WalSegSz)
271271
{
272-
pg_log_warning("segment file \"%s\" has incorrect size %d, skipping",
273-
dirent->d_name, (int) statbuf.st_size);
272+
pg_log_warning("segment file \"%s\" has incorrect size %lld, skipping",
273+
dirent->d_name, (long long int) statbuf.st_size);
274274
continue;
275275
}
276276
}

src/bin/pg_verifybackup/pg_verifybackup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ parse_manifest_file(char *manifest_path, manifest_files_hash **ht_p,
411411
report_fatal_error("could not read file \"%s\": %m",
412412
manifest_path);
413413
else
414-
report_fatal_error("could not read file \"%s\": read %d of %zu",
415-
manifest_path, rc, (size_t) statbuf.st_size);
414+
report_fatal_error("could not read file \"%s\": read %d of %lld",
415+
manifest_path, rc, (long long int) statbuf.st_size);
416416
}
417417

418418
/* Close the manifest file. */
@@ -638,8 +638,8 @@ verify_backup_file(verifier_context *context, char *relpath, char *fullpath)
638638
if (m->size != sb.st_size)
639639
{
640640
report_backup_error(context,
641-
"\"%s\" has size %zu on disk but size %zu in the manifest",
642-
relpath, (size_t) sb.st_size, m->size);
641+
"\"%s\" has size %lld on disk but size %zu in the manifest",
642+
relpath, (long long int) sb.st_size, m->size);
643643
m->bad = true;
644644
}
645645

src/fe_utils/archive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ RestoreArchivedFile(const char *path, const char *xlogfname,
7171
{
7272
if (expectedSize > 0 && stat_buf.st_size != expectedSize)
7373
{
74-
pg_log_fatal("unexpected file size for \"%s\": %lu instead of %lu",
75-
xlogfname, (unsigned long) stat_buf.st_size,
76-
(unsigned long) expectedSize);
74+
pg_log_fatal("unexpected file size for \"%s\": %lld instead of %lld",
75+
xlogfname, (long long int) stat_buf.st_size,
76+
(long long int) expectedSize);
7777
exit(1);
7878
}
7979
else

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy