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

RE: [XEN RFC PATCH 01/40] tools: Fix -Werror=maybe-uninitialized for xlu_pci_parse_bdf


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Fri, 13 Aug 2021 06:28:32 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QsoC1JKFxOYQzfsJ+7RRD+xWmeHR80dUYyVqKZ4y788=; b=E10g75nq4469J9T6bptJfy0Flk8hqXcd8QGqQa8eUag+y14Ptkx0g/Xwru7ftukYzbd0Wnr6KBi6RMOKeAbqYvBEWmoD2/fh8aRnNNGFjh19dmLDp2G7x8ULfxyFH3P5vWyT7cc836/zRNW+WCnp8BxoKMO6dFwGQo7uG8wAw8odtYrTeoqPteahmtIMFczuMjMbDwp/5cL+bhEGuRXlCzXJP/WWVZFhLy1Y1htuEGwH61IjCpDyNnHMyyb/H/cQJYI0Nqwgvt7h6YyHmsb/6gCca6Isa9Vdm2JY0jbLUAgy2Rl1IgPQL+HwcDNCpV9qU1Xzy+DLDFZ8Z2KBc3V7fQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RYXB4pHR23tlZdFW7atmAZlE3KuIvjO8nLm8X1jUIuKVY7CgjvjII2e8L0GOfEEWgVOYUKv1XjYjpT2IMMNilQxlxweJaGJbP1OJXYGbu1f55zisnfT3EIQBy6gSiMTtUSj0R+jf8Z40qULC206k2+74FrgpOStXbqoRZCpxdA9kkC7Y3aA3yN4VWPUfJXrd610Yb9a6TC6FMS1IC9cH5vKa1BXxdOGeEsIg05GGd8ZXSPZbHLiVeM6+6GVl0q/zQiGxMAJXElKzZvbhHCDNxmbvMcF3aghUrnCrU7z13+YVXtdvYYj+y2FujjLvFBcNeap4D0QerVNWa6eFUAzOcg==
  • Authentication-results-original: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>
  • Delivery-date: Fri, 13 Aug 2021 06:29:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHXjpsap9qHPnLZB0C8E1beBnV9NKtuIASAgALaSHA=
  • Thread-topic: [XEN RFC PATCH 01/40] tools: Fix -Werror=maybe-uninitialized for xlu_pci_parse_bdf

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: 2021年8月11日 18:50
> To: Wei Chen <Wei.Chen@xxxxxxx>
> Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>; xen-
> devel@xxxxxxxxxxxxxxxxxxxx; sstabellini@xxxxxxxxxx; julien@xxxxxxx
> Subject: Re: [XEN RFC PATCH 01/40] tools: Fix -Werror=maybe-uninitialized
> for xlu_pci_parse_bdf
> 
> On 11.08.2021 12:23, Wei Chen wrote:
> > | libxlu_pci.c: In function 'xlu_pci_parse_bdf':
> > | libxlu_pci.c:32:18: error: 'func' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> > |    32 |     pcidev->func = func;
> > |       |     ~~~~~~~~~~~~~^~~~~~
> 
> I'm afraid I can't spot such an assignment in the file (nor the two
> similar ones further down). All I can see is
> 
>     pci->domain = domain;
>     pci->bus = bus;
>     pci->dev = dev;
>     pci->func = func;
> 

Sorry, I forgot to update my commit log with the latest code base.
I revert this change in my current code, I can't reproduce it.
I'm not sure if it's because I upgraded my build environment.
Give me sometime, if I can reproduce it I will update the commit
log in next version. If it's no longer needed, I will remove this
patch from this series.

> > | libxlu_pci.c:51:29: note: 'func' was declared here
> > |    51 |     unsigned dom, bus, dev, func, vslot = 0;
> > |       |                             ^~~~
> > | libxlu_pci.c:31:17: error: 'dev' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> > |    31 |     pcidev->dev = dev;
> > |       |     ~~~~~~~~~~~~^~~~~
> > | libxlu_pci.c:51:24: note: 'dev' was declared here
> > |    51 |     unsigned dom, bus, dev, func, vslot = 0;
> > |       |                        ^~~
> > | libxlu_pci.c:30:17: error: 'bus' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> > |    30 |     pcidev->bus = bus;
> > |       |     ~~~~~~~~~~~~^~~~~
> > | libxlu_pci.c:51:19: note: 'bus' was declared here
> > |    51 |     unsigned dom, bus, dev, func, vslot = 0;
> > |       |                   ^~~
> > | libxlu_pci.c:78:26: error: 'dom' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> > |    78 |                 if ( dom & ~0xff )
> > |       |                      ~~~~^~~~~~~
> 
> I'm afraid I also can't spot a variable named "dom", nor a sufficiently
> similar if(). May I ask what code base these were observed with? Is the
> change needed at all anymore?
> 

same as above.

> > --- a/tools/libs/util/libxlu_pci.c
> > +++ b/tools/libs/util/libxlu_pci.c
> > @@ -15,7 +15,7 @@ static int parse_bdf(libxl_device_pci *pci, const char
> *str, const char **endp)
> >  {
> >      const char *ptr = str;
> >      unsigned int colons = 0;
> > -    unsigned int domain, bus, dev, func;
> > +    unsigned int domain = 0, bus = 0, dev = 0, func = 0;
> >      int n;
> >
> >      /* Count occurrences of ':' to detrmine presence/absence of the
> 'domain' */
> > @@ -28,7 +28,6 @@ static int parse_bdf(libxl_device_pci *pci, const char
> *str, const char **endp)
> >      ptr = str;
> >      switch (colons) {
> >      case 1:
> > -        domain = 0;
> >          if (sscanf(ptr, "%x:%x.%n", &bus, &dev, &n) != 2)
> >              return ERROR_INVAL;
> >          break;
> >
> 
> Also - which compiler did you encounter this with?
> 
> Finally please don't forget to Cc maintainers.
> 

If this patch still needed, I will do in next version.

> Jan


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.