[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this
From: |
Paul Menzel |
Subject: |
Re: fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this function [-Werror=maybe-uninitialized] |
Date: |
Thu, 26 Mar 2020 09:39:16 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 |
Dear PGNet Dev,
Thank you for your report.
Am 26.03.20 um 04:50 schrieb PGNet Dev:
building
cd grub
git log | head -n5
commit 552c9fd08122a3036c724ce96dfe68aa2f75705f
Author: Patrick Steinhardt <address@hidden>
Date: Sat Mar 7 17:29:09 2020 +0100
gnulib: Fix build of base64 when compiling with memory
debugging
with
gcc --version
gcc (SUSE Linux) 10.0.1 20200324 (experimental) [revision
75c24a08d697d6442fe6c26142f0559f803af977]
patched
patch -p1 <
/tmp/grub_patches/grub_patches/0001-mdraid1x_linux-Fix-gcc10-error-Werror-array-bounds.patch
patching file grub-core/disk/mdraid1x_linux.c
patch -p1 <
/tmp/grub_patches/grub_patches/0002-zfs-Fix-gcc10-error-Werror-zero-length-bounds.patch
patching file grub-core/fs/zfs/zfs.c
patching file include/grub/zfs/zap_leaf.h
from
https://lists.gnu.org/archive/html/grub-devel/2020-03/msg00222.html
config's ok
unset CC CPP
./bootstrap
./autogen.sh
./configure
build FAILs
make V=1
gcc -DHAVE_CONFIG_H -I. -Wall -W -DGRUB_UTIL=1 -D_FILE_OFFSET_BITS=64
-I./include -DGRUB_FILE=\"grub-core/fs/ntfscomp.c\" -I. -I. -I. -I. -I./include
-I./include -I./grub-core/lib/libgcrypt-grub/src/ -I./grub-core/lib/minilzo
-I./grub-core/lib/xzembed -I./grub-core/lib/zstd -DMINILZO_HAVE_CONFIG_H -O3 -Wall
-fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0
-grecord-gcc-switches -march=native -mtune=native -D_FORTIFY_SOURCE=2
-D_FILE_OFFSET_BITS=64 -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts
-Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal
-Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit
-Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces
-Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point
-Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function
-Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings
-Wnested-externs -Wstrict-prototypes -Wcast-align -Wextra -Wattributes -Wendif-labels
-Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull
-Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros
-Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes
-Wmissing-declarations -Wformat=2 -Werror -fno-builtin -Wno-undef -O3 -Wall
-fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0
-grecord-gcc-switches -march=native -mtune=native -MT
grub-core/fs/libgrubmods_a-ntfscomp.o -MD -MP -MF
grub-core/fs/.deps-util/libgrubmods_a-ntfscomp.Tpo -c -o
grub-core/fs/libgrubmods_a-ntfscomp.o `test -f 'grub-core/fs/ntfscomp.c' || echo
'./'`grub-core/fs/ntfscomp.c
grub-core/fs/ntfscomp.c: In function ‘read_block’:
grub-core/fs/ntfscomp.c:82:11: error: ‘flg’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
82 | if (flg & 0x8000)
| ^~~
grub-core/fs/ntfscomp.c:74:17: note: ‘flg’ was declared here
74 | grub_uint16_t flg, cnt;
| ^~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:7647:
grub-core/fs/libgrubmods_a-ntfscomp.o] Error 1
make[2]: Leaving directory '/usr/local/src/grub'
make[1]: *** [Makefile:11920: all-recursive] Error 1
make[1]: Leaving directory '/usr/local/src/grub'
make: *** [Makefile:3772: all] Error 2
I am unable to reproduce this with
$ gcc --version
gcc (Debian 10-20200324-1) 10.0.1 20200324 (experimental) [master
revision 596c90d3559:023579257f5:906b3eb9df6c577d3f6e9c3ea5c9d7e4d1e90536]
Here is the code in question:
``
static grub_err_t
decomp_get16 (struct grub_ntfs_comp *cc, grub_uint16_t * res)
{
grub_uint8_t c1 = 0, c2 = 0;
if ((decomp_getch (cc, &c1)) || (decomp_getch (cc, &c2)))
return grub_errno;
*res = ((grub_uint16_t) c2) * 256 + ((grub_uint16_t) c1);
return 0;
}
[…]
grub_uint16_t flg, cnt;
if (decomp_get16 (cc, &flg))
return grub_errno;
cnt = (flg & 0xFFF) + 1;
if (dest)
{
if (flg & 0x8000)
[…]
```
In the code, the `if (decomp_get16 (cc, &flg))` ensures, that `flg` is
initialized, doesn’t it?
Why is it complaining complaining in line 82 and not 78, where `flg` is
already accessed?
Kind regards,
Paul
- fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this function [-Werror=maybe-uninitialized], PGNet Dev, 2020/03/25
- Re: fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this function [-Werror=maybe-uninitialized],
Paul Menzel <=
- Re: fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this function [-Werror=maybe-uninitialized], Michael Chang, 2020/03/26
- Re: fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this function [-Werror=maybe-uninitialized], PGNet Dev, 2020/03/26
- Re: fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this function [-Werror=maybe-uninitialized], Daniel Kiper, 2020/03/27
- Re: fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this function [-Werror=maybe-uninitialized], PGNet Dev, 2020/03/27
- Re: fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this function [-Werror=maybe-uninitialized], Michael Chang, 2020/03/30
- Re: fs/ntfscomp.c:82:11: error: ‘flg’ may be used uninitialized in this function [-Werror=maybe-uninitialized], Daniel Kiper, 2020/03/31