From 053869284db064aa21b2249981ec6affa489e296 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 31 Dec 2019 12:19:39 -0600 Subject: [PATCH] INTEGRAL_ASSIGNMENT_FITS: actually provide return value for clang Apparently clang does need the pragmas, so either I tested it incorrectly before, or my local clang is different. It looks like clang doesn't ignore the pragmas as far as the expression result value is concerned, so explicitly put the value at the end. Signed-off-by: Rob Browning Tested-by: Rob Browning --- lib/bup/_helpers.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index b29c54c..d325578 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -129,13 +129,6 @@ static uint64_t htonll(uint64_t value) #endif -#ifdef __clang__ -#define INTEGRAL_ASSIGNMENT_FITS(dest, src) \ - ({ \ - *(dest) = (src); \ - *(dest) == (src) && (*(dest) < 1) == ((src) < 1); \ - }) -#else // Disabling sign-compare here should be fine since we're explicitly // checking for a sign mismatch, i.e. if the signs don't match, then // it doesn't matter what the value comparison says. @@ -145,10 +138,10 @@ static uint64_t htonll(uint64_t value) _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wsign-compare\""); \ *(dest) = (src); \ - *(dest) == (src) && (*(dest) < 1) == ((src) < 1); \ + int result = *(dest) == (src) && (*(dest) < 1) == ((src) < 1); \ _Pragma("GCC diagnostic pop"); \ + result; \ }) -#endif // At the moment any code that calls INTEGER_TO_PY() will have to -- 2.39.2