s4/torture/raw: cppcheck: Fix shiftTooManyBitsSigned error
authorNoel Power <noel.power@suse.com>
Wed, 22 May 2019 11:29:33 +0000 (11:29 +0000)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 4 Jun 2019 22:13:07 +0000 (22:13 +0000)
Fix

source4/torture/raw/open.c:1009: error: shiftTooManyBitsSigned: Shifting signed 32-bit value by 31 bits is undefined behaviour <--[cppcheck]
source4/torture/raw/open.c:1048: error: shiftTooManyBitsSigned: Shifting signed 32-bit value by 31 bits is undefined behaviour <--[cppcheck]

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/torture/raw/open.c

index 5e8c81c9d073f69c9061755e95b0d07547283fc0..220313ed83d2a8d0974873e2deb166e0358569ca 100644 (file)
@@ -1006,7 +1006,8 @@ static bool test_nttrans_create(struct torture_context *tctx, struct smbcli_stat
 
        /* Check some create options (these all should be ignored) */
        for (i=0; i < 32; i++) {
-               uint32_t create_option = (1 << i) & NTCREATEX_OPTIONS_MUST_IGNORE_MASK;
+               uint32_t create_option =
+                       ((uint32_t)1 << i) & NTCREATEX_OPTIONS_MUST_IGNORE_MASK;
                if (create_option == 0) {
                        continue;
                }
@@ -1045,7 +1046,7 @@ static bool test_nttrans_create(struct torture_context *tctx, struct smbcli_stat
        not_a_directory_mask = 0;
        unexpected_mask = 0;
        for (i=0; i < 32; i++) {
-               uint32_t create_option = 1<<i;
+               uint32_t create_option = (uint32_t)1<<i;
                if (create_option & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) {
                        continue;
                }