qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/4] crypto/luks: Initialize stack variable to silence war


From: Daniel P . Berrangé
Subject: Re: [PATCH v3 1/4] crypto/luks: Initialize stack variable to silence warning
Date: Wed, 1 Mar 2023 08:53:35 +0000
User-agent: Mutt/2.2.9 (2022-11-12)

On Tue, Feb 28, 2023 at 01:48:01PM -0700, Daniel Xu wrote:
> With `../configure --enable-sanitizers`, I was getting the following
> build error:
> 
>         In file included from /usr/include/string.h:535,
>                          from /home/dxu/dev/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;
>               |            ^~~~~~~~~~~
>         cc1: all warnings being treated as errors
> 
> The function is actually correct -- in the cleanup branch `splitkeylen`
> usage is guarded by checking `splitkey` nullness. But the compiler is
> not smart enough to realize that.
> 
> Fix warning by initializing the variable.
> 
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
>  crypto/block-luks.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




reply via email to

[Prev in Thread] Current Thread [Next in Thread]