1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

lib/torture: protect torture_assert[_goto]() with a do { } while(0) block

This hopefully fixes a lot of coverity defects like:

Control flow issues  (DEADCODE)
Execution cannot reach this statement: ";".

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Stefan Metzmacher 2019-09-10 10:55:15 +02:00 committed by Jeremy Allison
parent c6b48490ac
commit 8270b8c0b2

View File

@ -249,18 +249,20 @@ void torture_warning(struct torture_context *test, const char *comment, ...) PRI
void torture_result(struct torture_context *test,
enum torture_result, const char *reason, ...) PRINTF_ATTRIBUTE(3,4);
#define torture_assert(torture_ctx,expr,cmt) \
#define torture_assert(torture_ctx,expr,cmt) do { \
if (!(expr)) { \
torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
return false; \
}
} \
} while(0)
#define torture_assert_goto(torture_ctx,expr,ret,label,cmt) \
#define torture_assert_goto(torture_ctx,expr,ret,label,cmt) do { \
if (!(expr)) { \
torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
ret = false; \
goto label; \
}
} \
} while(0)
#define torture_assert_werr_equal(torture_ctx, got, expected, cmt) \
do { WERROR __got = got, __expected = expected; \