Since pretty much everywhere else uses C23 ckd_* instead of intprops *_WRAV macros now, here is a patch for tar.
Collin
>From 7430a86f8eb055695724e735c8485f2867ca4172 Mon Sep 17 00:00:00 2001 From: Collin Funk <collin.fu...@gmail.com> Date: Sun, 21 Jul 2024 12:19:03 -0700 Subject: [PATCH] maint: prefer ckd_add to INT_ADD_WRAPV * gnulib.modules: Add stdckdint. * src/delete.c: Include stdckdint.h. (move_archive): Use ckd_mul and ckd_add. * src/system.c: Include stdckdint.h. (mtioseek): Use ckd_sub and ckd_add. --- gnulib.modules | 1 + src/delete.c | 7 ++++--- src/system.c | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gnulib.modules b/gnulib.modules index 48c0e4cb..e7210535 100644 --- a/gnulib.modules +++ b/gnulib.modules @@ -91,6 +91,7 @@ setenv snprintf stat-time stdbool +stdckdint stdint stpcpy stdopen diff --git a/src/delete.c b/src/delete.c index 8303415f..1b5c86e3 100644 --- a/src/delete.c +++ b/src/delete.c @@ -20,6 +20,7 @@ #include <system.h> #include "common.h" +#include <stdckdint.h> #include <rmt.h> static union block *new_record; @@ -61,9 +62,9 @@ move_archive (off_t count) idx_t short_size = position0 % record_size; idx_t start_offset = short_size ? record_size - short_size : 0; off_t increment, move_start; - if (INT_MULTIPLY_WRAPV (record_size, count, &increment) - || INT_ADD_WRAPV (position0, start_offset, &move_start) - || INT_ADD_WRAPV (move_start, increment, &position) + if (ckd_mul (&increment, record_size, count) + || ckd_add (&move_start, position0, start_offset) + || ckd_add (&position, move_start, increment) || position < 0) { ERROR ((0, EOVERFLOW, "lseek: %s", archive_name_array[0])); diff --git a/src/system.c b/src/system.c index eae0a17a..e37e88ad 100644 --- a/src/system.c +++ b/src/system.c @@ -21,6 +21,7 @@ #include "common.h" #include <priv-set.h> #include <rmt.h> +#include <stdckdint.h> #include <signal.h> #include <wordsplit.h> #include <poll.h> @@ -56,8 +57,8 @@ mtioseek (bool count_files, off_t count) ? (count < 0 ? MTBSF : MTFSF) : (count < 0 ? MTBSR : MTFSR)); if (! (count < 0 - ? INT_SUBTRACT_WRAPV (0, count, &operation.mt_count) - : INT_ADD_WRAPV (count, 0, &operation.mt_count)) + ? ckd_sub (&operation.mt_count, 0, count) + : ckd_add (&operation.mt_count, count, 0)) && (0 <= rmtioctl (archive, MTIOCTOP, &operation) || (errno == EIO && 0 <= rmtioctl (archive, MTIOCTOP, &operation)))) -- 2.45.2