diff options
author | Stefan Metzmacher <metze@samba.org> | 2019-09-10 10:55:15 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-09-10 17:38:40 +0000 |
commit | 8270b8c0b2141e3db1cba16b72d152686efe824f (patch) | |
tree | 1e1d9eb6dbbbe45d91f3cc3e99481f05b71d6938 /lib/torture | |
parent | c6b48490ac68f23c9f172bdfa91954a960928795 (diff) | |
download | samba-8270b8c0b2141e3db1cba16b72d152686efe824f.tar.gz |
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>
Diffstat (limited to 'lib/torture')
-rw-r--r-- | lib/torture/torture.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/torture/torture.h b/lib/torture/torture.h index 3507740967c..dbc711e25a1 100644 --- a/lib/torture/torture.h +++ b/lib/torture/torture.h @@ -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; \ |