From 6dc62c1ab744726ca855de4f88c2a61ef2b6d590 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 6 Mar 2021 01:43:54 +0000 Subject: [PATCH] Remove redundant assignments when byteswapping. The SWAP_ macros already write the result to their destination arg, so there's no need for an extra assignment -- and this is undefined behaviour because there are two assignments to the same variable without an intervening sequence point (as GCC 10 correctly warns). --- byteswap.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/byteswap.c b/byteswap.c index 2f51983..fe9e2a1 100644 --- a/byteswap.c +++ b/byteswap.c @@ -123,8 +123,8 @@ swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all) * swap or copy the rest of the ZVALUE elements */ if (all) { - dest->len = (LEN)SWAP_B8_IN_LEN(&dest->len, &src->len); - dest->sign = (BOOL)SWAP_B8_IN_BOOL(&dest->sign, &src->sign); + SWAP_B8_IN_LEN(&dest->len, &src->len); + SWAP_B8_IN_BOOL(&dest->sign, &src->sign); } else { dest->len = src->len; dest->sign = src->sign; @@ -189,7 +189,7 @@ swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all) * swap or copy the rest of the NUMBER elements */ if (all) { - dest->links = (long)SWAP_B8_IN_LONG(&dest->links, &src->links); + SWAP_B8_IN_LONG(&dest->links, &src->links); } else { dest->links = src->links; } @@ -253,7 +253,7 @@ swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all) * swap or copy the rest of the NUMBER elements */ if (all) { - dest->links = (long)SWAP_B8_IN_LONG(&dest->links, &src->links); + SWAP_B8_IN_LONG(&dest->links, &src->links); } else { dest->links = src->links; } @@ -358,8 +358,8 @@ swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all) * swap or copy the rest of the ZVALUE elements */ if (all) { - dest->len = (LEN)SWAP_B16_IN_LEN(&dest->len, &src->len); - dest->sign = (BOOL)SWAP_B16_IN_BOOL(&dest->sign, &src->sign); + SWAP_B16_IN_LEN(&dest->len, &src->len); + SWAP_B16_IN_BOOL(&dest->sign, &src->sign); } else { dest->len = src->len; dest->sign = src->sign; @@ -424,7 +424,7 @@ swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all) * swap or copy the rest of the NUMBER elements */ if (all) { - dest->links = (long)SWAP_B16_IN_LONG(&dest->links, &src->links); + SWAP_B16_IN_LONG(&dest->links, &src->links); } else { dest->links = src->links; } @@ -488,7 +488,7 @@ swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all) * swap or copy the rest of the NUMBER elements */ if (all) { - dest->links = (long)SWAP_B16_IN_LONG(&dest->links, &src->links); + SWAP_B16_IN_LONG(&dest->links, &src->links); } else { dest->links = src->links; } @@ -554,8 +554,8 @@ swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all) * swap or copy the rest of the ZVALUE elements */ if (all) { - dest->len = (LEN)SWAP_HALF_IN_LEN(&dest->len, &src->len); - dest->sign = (BOOL)SWAP_HALF_IN_BOOL(&dest->sign, &src->sign); + SWAP_HALF_IN_LEN(&dest->len, &src->len); + SWAP_HALF_IN_BOOL(&dest->sign, &src->sign); } else { dest->len = src->len; dest->sign = src->sign; @@ -620,7 +620,7 @@ swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all) * swap or copy the rest of the NUMBER elements */ if (all) { - dest->links = (long)SWAP_HALF_IN_LONG(&dest->links,&src->links); + SWAP_HALF_IN_LONG(&dest->links, &src->links); } else { dest->links = src->links; } @@ -684,7 +684,7 @@ swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all) * swap or copy the rest of the NUMBER elements */ if (all) { - dest->links = (long)SWAP_HALF_IN_LONG(&dest->links,&src->links); + SWAP_HALF_IN_LONG(&dest->links, &src->links); } else { dest->links = src->links; }