]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/torture/smb2/oplock: fix compilation by initialising variable
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 14 Jul 2020 10:31:02 +0000 (22:31 +1200)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2020 05:55:49 +0000 (05:55 +0000)
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>
source4/torture/smb2/oplock.c

index ef52a7cc38130ddbd013933bde9d0903df71b539..a30657ef596bc8cdce8e4b63f6b3ff88284f8405 100644 (file)
@@ -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);