linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Jens Axboe <axboe@kernel.dk>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Cc: Christoph Hellwig <hch@lst.de>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: Re: [block:for-linus 20/23] include/linux/kernel.h:62:48: warning: 'zone_blocks' may be used uninitialized in this function
Date: Mon, 15 Jul 2019 23:41:26 +0000	[thread overview]
Message-ID: <BYAPR04MB5816248A733264DC19E050C0E7CF0@BYAPR04MB5816.namprd04.prod.outlook.com> (raw)
In-Reply-To: 279546ac-9089-d5fc-f26c-9e46db269623@kernel.dk

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@intel.com>
>>>
>>> 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

      reply	other threads:[~2019-07-15 23:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201907131730.Br9OqtbO%lkp@intel.com>
2019-07-15  5:43 ` [block:for-linus 20/23] include/linux/kernel.h:62:48: warning: 'zone_blocks' may be used uninitialized in this function Damien Le Moal
2019-07-15 13:56   ` Jens Axboe
2019-07-15 23:41     ` Damien Le Moal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BYAPR04MB5816248A733264DC19E050C0E7CF0@BYAPR04MB5816.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).