diff options
author | Robert Haas <rhaas@postgresql.org> | 2023-08-01 13:50:42 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2023-08-01 13:50:42 -0400 |
commit | 6050b6a92d1e6b5a234e96382ea711683e67d280 (patch) | |
tree | d65fe86fe5ff5e09b3e3d025f266014e458fa7c7 /src/bin/pg_basebackup/walmethods.c | |
parent | deae1657ee6dd6f7b3effab3d44429d5434f5bbf (diff) |
Add and use symbolic constants for tar header offsets and file types.
Because symbolic constants in a header file are better than magic
constants embedded in the code.
Patch by me, reviewed by Tom Lane, Dagfinn Ilmari Mannsåker, and
Tristan Partin.
Discussion: http://postgr.es/m/CA+TgmoZNbLwhmCrNtkJAvi8FLkwFdMeVU3myV2HQQpA5bvbRZg@mail.gmail.com
Diffstat (limited to 'src/bin/pg_basebackup/walmethods.c')
-rw-r--r-- | src/bin/pg_basebackup/walmethods.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c index 376ddf72b71..d780c4055cd 100644 --- a/src/bin/pg_basebackup/walmethods.c +++ b/src/bin/pg_basebackup/walmethods.c @@ -1131,7 +1131,7 @@ tar_close(Walfile *f, WalCloseMethod method) * possibly also renaming the file. We overwrite the entire current header * when done, including the checksum. */ - print_tar_number(&(tf->header[124]), 12, filesize); + print_tar_number(&(tf->header[TAR_OFFSET_SIZE]), 12, filesize); if (method == CLOSE_NORMAL) @@ -1139,9 +1139,10 @@ tar_close(Walfile *f, WalCloseMethod method) * We overwrite it with what it was before if we have no tempname, * since we're going to write the buffer anyway. */ - strlcpy(&(tf->header[0]), tf->base.pathname, 100); + strlcpy(&(tf->header[TAR_OFFSET_NAME]), tf->base.pathname, 100); - print_tar_number(&(tf->header[148]), 8, tarChecksum(((TarMethodFile *) f)->header)); + print_tar_number(&(tf->header[TAR_OFFSET_CHECKSUM]), 8, + tarChecksum(((TarMethodFile *) f)->header)); if (lseek(tar_data->fd, tf->ofs_start, SEEK_SET) != ((TarMethodFile *) f)->ofs_start) { f->wwmethod->lasterrno = errno; |