From: Douglas Bagnall Date: Tue, 14 Jul 2020 10:31:02 +0000 (+1200) Subject: s4/torture/smb2/oplock: fix compilation by initialising variable X-Git-Tag: talloc-2.3.2~1088 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e4e18d0c0619fb407a12768caa8c7125ab30d42;p=thirdparty%2Fsamba.git s4/torture/smb2/oplock: fix compilation by initialising variable With gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0: ../../source4/torture/smb2/oplock.c:2709:2: error: variable 'h2' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "Incorrect status"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../lib/torture/torture.h:734:3: note: expanded from macro 'torture_assert_ntstatus_ok_goto' torture_assert_ntstatus_equal_goto(torture_ctx,expr,NT_STATUS_OK,ret,label,cmt) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../lib/torture/torture.h:302:6: note: expanded from macro 'torture_assert_ntstatus_equal_goto' if (!NT_STATUS_EQUAL(__got, __expected)) { \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../source4/torture/smb2/oplock.c:2730:25: note: uninitialized use occurs here smb2_util_close(tree1, h2); ^~ ../../source4/torture/smb2/oplock.c:2709:2: note: remove the 'if' if its condition is always false torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "Incorrect status"); ^ ../../lib/torture/torture.h:734:3: note: expanded from macro 'torture_assert_ntstatus_ok_goto' torture_assert_ntstatus_equal_goto(torture_ctx,expr,NT_STATUS_OK,ret,label,cmt) ^ ../../lib/torture/torture.h:302:2: note: expanded from macro 'torture_assert_ntstatus_equal_goto' if (!NT_STATUS_EQUAL(__got, __expected)) { \ ^ ../../source4/torture/smb2/oplock.c:2652:2: note: variable 'h2' is declared here struct smb2_handle h, h1, h2; ^ 1 error generated. Signed-off-by: Douglas Bagnall Reviewed-by: Ralph Boehme --- diff --git a/source4/torture/smb2/oplock.c b/source4/torture/smb2/oplock.c index ef52a7cc381..a30657ef596 100644 --- a/source4/torture/smb2/oplock.c +++ b/source4/torture/smb2/oplock.c @@ -2649,7 +2649,7 @@ static bool test_smb2_oplock_batch22b(struct torture_context *tctx, NTSTATUS status; bool ret = true; union smb_open io; - struct smb2_handle h, h1, h2; + struct smb2_handle h, h1, h2 = {{0}}; struct timeval tv; int timeout = torture_setting_int(tctx, "oplocktimeout", 35); struct smb2_transport *transport1 = tree1->session->transport; @@ -2727,7 +2727,9 @@ done: test_cleanup_blocked_transports(tctx); smb2_util_close(tree1, h1); - smb2_util_close(tree1, h2); + if (!smb2_util_handle_empty(h2)) { + smb2_util_close(tree1, h2); + } smb2_util_close(tree1, h); smb2_deltree(tree1, BASEDIR);