samba-o3: fix -Werror=strict-overflow error in s4/torture/raw/eas module
authorJoe Guo <joeg@catalyst.net.nz>
Wed, 19 Dec 2018 01:37:33 +0000 (14:37 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 8 Mar 2019 00:42:19 +0000 (00:42 +0000)
samba-o3 test failed in ubuntu:16.04 docker container:

    ==> /home/samba/samba/samba-o3.stderr <==
    ../../source4/torture/raw/eas.c: In function ‘test_max_eas’:
    ../../source4/torture/raw/eas.c:286:12: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
     static bool test_max_eas(struct smbcli_state *cli, struct torture_context *tctx)
                ^
    cc1: all warnings being treated as errors

`total += j` may overflow. Change total type to `size_t` to mute error.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/torture/raw/eas.c

index eace20ae83a367d7182fe95eacb61dcbf6dffbc3..59baae53ad620adaf0aa02bf4534b07282bf720e 100644 (file)
@@ -292,7 +292,8 @@ static bool test_max_eas(struct smbcli_state *cli, struct torture_context *tctx)
        bool ret = true;
        bool err = false;
 
-       int       i, j, k, last, total;
+       int       i, j, k, last;
+       size_t total;
        DATA_BLOB eablob;
        char      *eaname = NULL;
        int       maxeasize;
@@ -398,7 +399,7 @@ static bool test_max_eas(struct smbcli_state *cli, struct torture_context *tctx)
                last = j;
        }
 
-       torture_comment(tctx, "Total EA size:%d\n", total);
+       torture_comment(tctx, "Total EA size:%zu\n", total);
        if (i == maxeanames) {
                torture_comment(tctx, "NOTE: More EAs could be available!\n");
        }