lib:crypto: Fix Coverity build
authorJo Sutton <josutton@catalyst.net.nz>
Sun, 21 Apr 2024 23:10:00 +0000 (11:10 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 24 Apr 2024 05:16:29 +0000 (05:16 +0000)
The Coverity build is failing with the following errors:

[1936/5164] Compiling lib/crypto/gkdi.c
In file included from /usr/lib64/gcc/x86_64-suse-linux/7/include/stdint.h:9:0,
                 from /usr/include/inttypes.h:27,
                 from ../../lib/crypto/../replace/replace.h:64,
                 from ../../source4/include/includes.h:23,
                 from ../../lib/crypto/gkdi.c:21:
../../lib/crypto/gkdi.c: In function ‘gkdi_get_key_start_time’:
../../lib/crypto/gkdi.c:197:4: error: initializer element is not constant
    UINT64_MAX /
    ^
../../lib/crypto/gkdi.c:197:4: note: (near initialization for ‘max_gkid.l0_idx’)
../../lib/crypto/gkdi.c:200:4: error: initializer element is not constant
    UINT64_MAX /
    ^
../../lib/crypto/gkdi.c:200:4: note: (near initialization for ‘max_gkid.l1_idx’)
../../lib/crypto/gkdi.c:204:4: error: initializer element is not constant
    UINT64_MAX / gkdi_key_cycle_duration %
    ^
../../lib/crypto/gkdi.c:204:4: note: (near initialization for ‘max_gkid.l2_idx’)

Fix the build by removing the ‘static’ specifier on this constant.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/crypto/gkdi.c

index af00ea4217eb28858cb973d15412dde9f16c648c..ae269d64a3e1c9fc7c65470427180e095e2838b3 100644 (file)
@@ -193,7 +193,7 @@ bool gkdi_get_key_start_time(const struct Gkid gkid, NTTIME *start_time_out)
                 * Make sure that the GKID is not so large its start time can’t
                 * be represented in NTTIME.
                 */
-               static const struct Gkid max_gkid = {
+               const struct Gkid max_gkid = {
                        UINT64_MAX /
                                (gkdi_l1_key_iteration * gkdi_l2_key_iteration *
                                 gkdi_key_cycle_duration),