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 <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Ralph Boehme <slow@samba.org>
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;
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);