From 34b775ca5063220f6faab56d1b82dcd42f8ac9fa Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 3 Oct 2021 14:21:27 -0500 Subject: [PATCH] Drop builtin_mul_overflow in favor of INT_MULTIPLY_OK Now that we have intprops.h drop built_mul_overflow (since intpropos.h should use it when available). Signed-off-by: Rob Browning --- config/configure | 18 ------------------ lib/bup/_helpers.c | 10 +--------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/config/configure b/config/configure index f1faa6e..85495ae 100755 --- a/config/configure +++ b/config/configure @@ -165,24 +165,6 @@ fi AC_CHECK_FUNCS utimes AC_CHECK_FUNCS lutimes -builtin_mul_overflow_code=" -#include -int main(int argc, char **argv) -{ - size_t n = 0, size = 0, total; - __builtin_mul_overflow(n, size, &total); - return 0; -} -" - -TLOGN "checking for __builtin_mul_overflow" -if bup_try_c_code "$builtin_mul_overflow_code"; then - AC_DEFINE BUP_HAVE_BUILTIN_MUL_OVERFLOW 1 - TLOG ' (found)' -else - TLOG ' (not found)' -fi - AC_CHECK_FUNCS mincore diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index cb5e934..391597f 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -125,16 +125,10 @@ static void *checked_calloc(size_t n, size_t size) return result; } -#ifndef BUP_HAVE_BUILTIN_MUL_OVERFLOW - -#define checked_malloc checked_calloc - -#else // defined BUP_HAVE_BUILTIN_MUL_OVERFLOW - static void *checked_malloc(size_t n, size_t size) { size_t total; - if (__builtin_mul_overflow(n, size, &total)) + if (!INT_MULTIPLY_OK(n, size, &total)) { PyErr_Format(PyExc_OverflowError, "request to allocate %zu items of size %zu is too large", @@ -147,8 +141,6 @@ static void *checked_malloc(size_t n, size_t size) return result; } -#endif // defined BUP_HAVE_BUILTIN_MUL_OVERFLOW - #ifndef htonll // This function should technically be macro'd out if it's going to be used -- 2.39.2