On 11/25/21 16:30, Richard W.M. Jones wrote:
In file included from test-checked-overflow.c:38:0:
../../common/include/checked-overflow.h:146:10: error: declaration of ‘overflow’ shadows
a previous local [-Werror=shadow]
bool overflow; \
^
---
common/utils/test-checked-overflow.c | 46 ++++++++++++++--------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/common/utils/test-checked-overflow.c b/common/utils/test-checked-overflow.c
index c2882e38..cfbcb4f2 100644
--- a/common/utils/test-checked-overflow.c
+++ b/common/utils/test-checked-overflow.c
@@ -39,25 +39,25 @@
#define TEST_ADD(a, b, result, expected_overflow, expected_result) \
do { \
- bool overflow; \
+ bool overflow0; \
\
- overflow = ADD_OVERFLOW_FALLBACK ((a), (b), (result)); \
- assert (overflow == (expected_overflow)); \
+ overflow0 = ADD_OVERFLOW_FALLBACK ((a), (b), (result)); \
+ assert (overflow0 == (expected_overflow)); \
assert (*(result) == (expected_result)); \
- overflow = ADD_OVERFLOW_FALLBACK ((b), (a), (result)); \
- assert (overflow == (expected_overflow)); \
+ overflow0 = ADD_OVERFLOW_FALLBACK ((b), (a), (result)); \
+ assert (overflow0 == (expected_overflow)); \
assert (*(result) == (expected_result)); \
} while (0)
#define TEST_MUL(a, b, result, expected_overflow, expected_result) \
do { \
- bool overflow; \
+ bool overflow1; \
\
- overflow = MUL_OVERFLOW_FALLBACK ((a), (b), (result)); \
- assert (overflow == (expected_overflow)); \
+ overflow1 = MUL_OVERFLOW_FALLBACK ((a), (b), (result)); \
+ assert (overflow1 == (expected_overflow)); \
assert (*(result) == (expected_result)); \
- overflow = MUL_OVERFLOW_FALLBACK ((b), (a), (result)); \
- assert (overflow == (expected_overflow)); \
+ overflow1 = MUL_OVERFLOW_FALLBACK ((b), (a), (result)); \
+ assert (overflow1 == (expected_overflow)); \
assert (*(result) == (expected_result)); \
} while (0)
@@ -84,7 +84,7 @@ main (void)
uint8_t u8;
size_t sz;
} result;
- bool overflow;
+ bool overflow2;
/* "max + 0" and "0 + max" evaluate to "max", without
overflow. */
TEST_ADD (umax_max, 0u, &result.umax, false, umax_max);
@@ -151,26 +151,26 @@ main (void)
*
* Perform the above multiplications, advacing with prime factors.
*/
- overflow = MUL_OVERFLOW_FALLBACK (3u, 5u, &result.u8);
- assert (!overflow);
+ overflow2 = MUL_OVERFLOW_FALLBACK (3u, 5u, &result.u8);
+ assert (!overflow2);
assert (result.u8 == 0xF);
- overflow = MUL_OVERFLOW_FALLBACK (result.u8, 17u, &result.u8);
- assert (!overflow);
+ overflow2 = MUL_OVERFLOW_FALLBACK (result.u8, 17u, &result.u8);
+ assert (!overflow2);
assert (result.u8 == UINT8_MAX);
- overflow = MUL_OVERFLOW_FALLBACK (result.u8, 257u, &result.u16);
- assert (!overflow);
+ overflow2 = MUL_OVERFLOW_FALLBACK (result.u8, 257u, &result.u16);
+ assert (!overflow2);
assert (result.u16 == UINT16_MAX);
- overflow = MUL_OVERFLOW_FALLBACK (result.u16, 65537ul, &result.u32);
- assert (!overflow);
+ overflow2 = MUL_OVERFLOW_FALLBACK (result.u16, 65537ul, &result.u32);
+ assert (!overflow2);
assert (result.u32 == UINT32_MAX);
- overflow = MUL_OVERFLOW_FALLBACK (result.u32, 641u, &result.u64);
- assert (!overflow);
- overflow = MUL_OVERFLOW_FALLBACK (result.u64, 6700417ul, &result.u64);
- assert (!overflow);
+ overflow2 = MUL_OVERFLOW_FALLBACK (result.u32, 641u, &result.u64);
+ assert (!overflow2);
+ overflow2 = MUL_OVERFLOW_FALLBACK (result.u64, 6700417ul, &result.u64);
+ assert (!overflow2);
assert (result.u64 == UINT64_MAX);
return 0;
We already have UNIQUE_VAR() :) I'll try to use that, instead.
Thanks!
Laszlo