mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/7] test: self: ramfs: fix unintended macro identifier confusion
@ 2023-05-22  5:22 Ahmad Fatoum
  2023-05-22  5:22 ` [PATCH master 2/7] include: zero_page: hide possibly NULL pointer variable from optimizer Ahmad Fatoum
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Ahmad Fatoum @ 2023-05-22  5:22 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

int ret = (_ret) is problematic, because when _ret is replaced with ret
in a macro, we end up with int ret = ret, which is valid syntactically,
but invokes undefined behavior. Guard against this by using different
identifiers.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 test/self/ramfs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/test/self/ramfs.c b/test/self/ramfs.c
index f8e1d60a61b5..bce396dc171e 100644
--- a/test/self/ramfs.c
+++ b/test/self/ramfs.c
@@ -14,17 +14,17 @@
 
 BSELFTEST_GLOBALS();
 
-#define __expect(_ret, _cond, fmt, ...) ({ \
-	bool cond = (_cond); \
-	int ret = (_ret); \
+#define __expect(ret, cond, fmt, ...) ({ \
+	bool __cond = (cond); \
+	int __ret = (ret); \
 	total_tests++; \
 	\
-	if (!cond) { \
+	if (!__cond) { \
 		failed_tests++; \
 		printf("%s:%d error %pe: " fmt "\n", \
-		       __func__, __LINE__, ERR_PTR(ret), ##__VA_ARGS__); \
+		       __func__, __LINE__, ERR_PTR(__ret), ##__VA_ARGS__); \
 	} \
-	cond; \
+	__cond; \
 })
 
 #define expect_success(ret, ...) __expect((ret), (ret) >= 0, __VA_ARGS__)
-- 
2.39.2




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-05-23  7:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22  5:22 [PATCH master 1/7] test: self: ramfs: fix unintended macro identifier confusion Ahmad Fatoum
2023-05-22  5:22 ` [PATCH master 2/7] include: zero_page: hide possibly NULL pointer variable from optimizer Ahmad Fatoum
2023-05-23  6:46   ` Ahmad Fatoum
2023-05-22  5:22 ` [PATCH master 3/7] ARM: configs: temporarily revive vexpress_defconfig Ahmad Fatoum
2023-05-22  8:23   ` Sascha Hauer
2023-05-22  8:36     ` Ahmad Fatoum
2023-05-22  5:22 ` [PATCH master 4/7] ARM64: configs: temporarily revive qemu_virt64_defconfig Ahmad Fatoum
2023-05-22  5:22 ` [PATCH master 5/7] pbl: have DEBUG_PBL depend only on PBL_CONSOLE Ahmad Fatoum
2023-05-22  5:22 ` [PATCH master 6/7] meminfo: avoid out-of-bounds compiler warning Ahmad Fatoum
2023-05-22  5:22 ` [PATCH master 7/7] console: don't fixup baud rate into earlycon string Ahmad Fatoum
2023-05-23  7:23 ` [PATCH master 1/7] test: self: ramfs: fix unintended macro identifier confusion Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox