summary refs log tree commit diff stats
path: root/tests/unit/test-string-input-visitor.c
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki@daynix.com>2023-05-22 20:47:37 +0900
committerDaniel P. Berrangé <berrange@redhat.com>2023-07-25 17:15:59 +0100
commit55a01cab83b608bae6345b7e0e2fbecc142c1b2f (patch)
tree5eab43d4a0b074b4329bb72cd9ffbae5810bf746 /tests/unit/test-string-input-visitor.c
parenta279ca4ea07383314b2d2b2f1d550be9482f148e (diff)
downloadfocaccia-qemu-55a01cab83b608bae6345b7e0e2fbecc142c1b2f.tar.gz
focaccia-qemu-55a01cab83b608bae6345b7e0e2fbecc142c1b2f.zip
crypto: Always initialize splitkeylen
When _FORTIFY_SOURCE=2, glibc version is 2.35, and GCC version is
12.1.0, the compiler complains as follows:

In file included from /usr/include/string.h:535,
                 from /home/alarm/q/var/qemu/include/qemu/osdep.h:99,
                 from ../crypto/block-luks.c:21:
In function 'memset',
    inlined from 'qcrypto_block_luks_store_key' at ../crypto/block-luks.c:843:9:
/usr/include/bits/string_fortified.h:59:10: error: 'splitkeylen' may be used uninitialized [-Werror=maybe-uninitialized]
   59 |   return __builtin___memset_chk (__dest, __ch, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   60 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
../crypto/block-luks.c: In function 'qcrypto_block_luks_store_key':
../crypto/block-luks.c:699:12: note: 'splitkeylen' was declared here
  699 |     size_t splitkeylen;
      |            ^~~~~~~~~~~

It seems the compiler cannot see that splitkeylen will not be used
when splitkey is NULL. Suppress the warning by initializing splitkeylen
even when splitkey stays NULL.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'tests/unit/test-string-input-visitor.c')
0 files changed, 0 insertions, 0 deletions