Re: [block:for-linus 20/23] include/linux/kernel.h:62:48: warning: 'zone_blocks' may be used uninitialized in this function

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

 



On 2019/07/15 22:56, Jens Axboe wrote:
> On 7/14/19 11:43 PM, Damien Le Moal wrote:
>> On 2019/07/13 18:10, kbuild test robot wrote:
>>> tree:   https://kernel.googlesource.com/pub/scm/linux/kernel/git/axboe/linux-block.git for-linus
>>> head:   787c79d6393fc028887cc1b6066915f0b094e92f
>>> commit: b091ac616846a1da75b1f2566b41255ce7f0e0a6 [20/23] sd_zbc: Fix report zones buffer allocation
>>> config: c6x-allyesconfig (attached as .config)
>>> compiler: c6x-elf-gcc (GCC) 7.4.0
>>> reproduce:
>>>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>>>          chmod +x ~/bin/make.cross
>>>          git checkout b091ac616846a1da75b1f2566b41255ce7f0e0a6
>>>          # save the attached .config to linux build tree
>>>          GCC_VERSION=7.4.0 make.cross ARCH=c6x
>>>
>>> If you fix the issue, kindly add following tag
>>> Reported-by: kbuild test robot <lkp@xxxxxxxxx>
>>>
>>> Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
>>> http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
>>>
>>> All warnings (new ones prefixed by >>):
>>>
>>>     In file included from include/asm-generic/bug.h:18:0,
>>>                      from arch/c6x/include/asm/bug.h:12,
>>>                      from include/linux/bug.h:5,
>>>                      from include/linux/thread_info.h:12,
>>>                      from include/asm-generic/current.h:5,
>>>                      from ./arch/c6x/include/generated/asm/current.h:1,
>>>                      from include/linux/sched.h:12,
>>>                      from include/linux/blkdev.h:5,
>>>                      from drivers//scsi/sd_zbc.c:11:
>>>     drivers//scsi/sd_zbc.c: In function 'sd_zbc_read_zones':
>>>>> include/linux/kernel.h:62:48: warning: 'zone_blocks' may be used uninitialized in this function [-Wmaybe-uninitialized]
>>>      #define __round_mask(x, y) ((__typeof__(x))((y)-1))
>>>                                                     ^
>>>     drivers//scsi/sd_zbc.c:464:6: note: 'zone_blocks' was declared here
>>>       u32 zone_blocks;
>>>           ^~~~~~~~~~~
>> [...]
>>
>> Jens,
>>
>> This warning does not show up on x86_64 native build with gcc 9.1.
>> I just sent a patch to remove the warning, but I do not have a c6x cross
>> compilation environment available so the patch was checked only on x86.
> 
> Is it a false positive, or is it legit?

It is a false positive: if sd_zbc_check_zones() returns success, zone_blocks is
always initialized. The zone_blocks variable is not initialized only if
sd_zbc_check_zones() fails, but in that case this variable is not used at all.

My guess is that gcc 7.4 warning is due to the error path, while gcc 9.1 does a
better job at detecting that the variable is not used in failure cases.

-- 
Damien Le Moal
Western Digital Research




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux