[PATCH master 1/7] test: self: ramfs: fix unintended macro identifier confusion
Ahmad Fatoum
a.fatoum at pengutronix.de
Sun May 21 22:22:16 PDT 2023
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 at 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
More information about the barebox
mailing list