Fix warning in memrchr.c

Message ID PAVPR08MB88458A36F367EDF9D1820E5AF94AA@PAVPR08MB8845.eurprd08.prod.outlook.com
State New
Headers
Series Fix warning in memrchr.c |

Commit Message

Federico Terraneo March 22, 2026, 1:40 p.m. UTC
  Hi,
the following patch fixes the warning reproted below, introduced by our 
previous patch.

Best regards,
Federico Terraneo


../../../newlib-4.6.0.20260123/newlib/libc/string/memrchr.c:50:26: 
warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
    50 |   while (UNALIGNED_X(src + 1))
../../../newlib-4.6.0.20260123/newlib/libc/string/local.h:24:31: note: 
in definition of macro 'UNALIGNED_X'
    24 | #define UNALIGNED_X(X) ((long)X & (sizeof (long) - 1))
       |                               ^
  

Comments

Corinna Vinschen March 23, 2026, 8:51 a.m. UTC | #1
On Mar 22 14:40, Federico Terraneo wrote:
> Hi,
> the following patch fixes the warning reproted below, introduced by our
> previous patch.
> 
> Best regards,
> Federico Terraneo

Pushed.

Thanks,
Corinna
  

Patch

From 990c134b82aae924bf6b7291aafdb28413f82da2 Mon Sep 17 00:00:00 2001
From: Terraneo Federico <fede.tft@miosix.org>
Date: Sun, 22 Mar 2026 12:12:19 +0100
Subject: [PATCH] libc: string: Fix warning in memrchr.c

---
 newlib/libc/string/local.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/newlib/libc/string/local.h b/newlib/libc/string/local.h
index 8cb43f8e3..012a30d16 100644
--- a/newlib/libc/string/local.h
+++ b/newlib/libc/string/local.h
@@ -21,7 +21,7 @@  int __wcwidth (wint_t);
  * This macro is used to skip a few bytes to find an aligned pointer.
  * It's better to keep it as is even if _HAVE_HW_MISALIGNED_ACCESS is enabled,
  * to avoid small performance penalties (if they are not zero).  */
-#define UNALIGNED_X(X) ((long)X & (sizeof (long) - 1))
+#define UNALIGNED_X(X) ((long)(X) & (sizeof (long) - 1))
 
 #ifdef _HAVE_HW_MISALIGNED_ACCESS
 /* Hardware performs unaligned operations with little
-- 
2.47.3