]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Print off_t/pgoff_t consistently as %lld
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 7 Jul 2026 09:50:22 +0000 (11:50 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 7 Jul 2026 09:50:22 +0000 (11:50 +0200)
This was the dominant style already, but some places used %llu
instead.  Since off_t/pgoff_t are signed types, using %lld seems a
better match, and it might handle obscure error conditions with
negative values better.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/20ce62fa-47fc-457b-b504-12f3c1651726%40eisentraut.org

src/bin/pg_combinebackup/reconstruct.c
src/bin/pg_dump/pg_backup_tar.c
src/bin/pg_rewind/libpq_source.c
src/bin/pg_verifybackup/astreamer_verify.c
src/bin/pg_verifybackup/pg_verifybackup.c

index 986c6e99b9d4a6f3b8626716101ca9c7492a8e53..47ba962de902e9842f1f2d80a16b96d6cd827e34 100644 (file)
@@ -421,10 +421,10 @@ debug_reconstruction(int n_source, rfile **sources, bool dry_run)
                        if (fstat(s->fd, &sb) < 0)
                                pg_fatal("could not stat file \"%s\": %m", s->filename);
                        if (sb.st_size < s->highest_offset_read)
-                               pg_fatal("file \"%s\" is too short: expected %llu, found %llu",
+                               pg_fatal("file \"%s\" is too short: expected %lld, found %lld",
                                                 s->filename,
-                                                (unsigned long long) s->highest_offset_read,
-                                                (unsigned long long) sb.st_size);
+                                                (long long) s->highest_offset_read,
+                                                (long long) sb.st_size);
                }
        }
 }
@@ -788,7 +788,7 @@ read_block(rfile *s, off_t off, uint8 *buffer)
                if (rb < 0)
                        pg_fatal("could not read from file \"%s\": %m", s->filename);
                else
-                       pg_fatal("could not read from file \"%s\", offset %llu: read %d of %d",
-                                        s->filename, (unsigned long long) off, rb, BLCKSZ);
+                       pg_fatal("could not read from file \"%s\", offset %lld: read %d of %d",
+                                        s->filename, (long long) off, rb, BLCKSZ);
        }
 }
index 9e9eaf0ba2af5da51c5daf48c9f1a0ccadc9e58f..542fdb453fb50971c881e547eb0a9f3ee1b602eb 100644 (file)
@@ -1169,12 +1169,12 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
 
        len = read_tar_number(&h[TAR_OFFSET_SIZE], 12);
 
-       pg_log_debug("TOC Entry %s at %llu (length %llu, checksum %d)",
-                                tag, (unsigned long long) hPos, (unsigned long long) len, sum);
+       pg_log_debug("TOC Entry %s at %lld (length %lld, checksum %d)",
+                                tag, (long long) hPos, (long long) len, sum);
 
        if (chk != sum)
-               pg_fatal("corrupt tar header found in %s (expected %d, computed %d) file position %llu",
-                                tag, sum, chk, (unsigned long long) ftello(ctx->tarFH));
+               pg_fatal("corrupt tar header found in %s (expected %d, computed %d) file position %lld",
+                                tag, sum, chk, (long long) ftello(ctx->tarFH));
 
        th->targetFile = pg_strdup(tag);
        th->fileLen = len;
index 6955bc575eaa2b8e3597d9aa86cd9ef73e319ee1..216755b3ddbffcaa2c9b232274cf741112a7d474 100644 (file)
@@ -458,7 +458,7 @@ process_queued_fetch_requests(libpq_source *src)
                }
 
                appendArrayEscapedString(&src->paths, rq->path);
-               appendStringInfo(&src->offsets, INT64_FORMAT, (int64) rq->offset);
+               appendStringInfo(&src->offsets, "%lld", (long long int) rq->offset);
                appendStringInfo(&src->lengths, "%zu", rq->length);
        }
        appendStringInfoChar(&src->paths, '}');
index 99bd69ce7c9ef1bcdafcf8f7aa9822fabec7379b..2578765b0cab73407ddb6ec4a94afc9b88506f9c 100644 (file)
@@ -208,9 +208,9 @@ member_verify_header(astreamer *streamer, astreamer_member *member)
        if (m->size != member->size)
        {
                report_backup_error(mystreamer->context,
-                                                       "file \"%s\" has size %llu in archive \"%s\" but size %" PRIu64 " in the manifest",
+                                                       "file \"%s\" has size %lld in archive \"%s\" but size %" PRIu64 " in the manifest",
                                                        member->pathname,
-                                                       (unsigned long long) member->size,
+                                                       (long long) member->size,
                                                        mystreamer->archive_name,
                                                        m->size);
                m->bad = true;
index f338fa22ca0a8a8729f2661839c1956ce40d3491..97f575944cd3c4c1ba49486be159ad80ead33590 100644 (file)
@@ -735,9 +735,9 @@ verify_plain_backup_file(verifier_context *context, char *relpath,
        if (m->size != sb.st_size)
        {
                report_backup_error(context,
-                                                       "\"%s\" has size %llu on disk but size %llu in the manifest",
-                                                       relpath, (unsigned long long) sb.st_size,
-                                                       (unsigned long long) m->size);
+                                                       "\"%s\" has size %lld on disk but size %" PRIu64 " in the manifest",
+                                                       relpath, (long long) sb.st_size,
+                                                       m->size);
                m->bad = true;
        }