[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: Wei Chen <wei.chen@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 11 Aug 2021 12:49:53 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=r6wCmGxzzOHJR43xy+qjJa5sUS/Jj0WuwOZ94L6wVyI=; b=lhDOEPJoj1nT2h0YCuyuYWsdlShB0x0kCJPX3b14W6Wu8C9C7TASHjA0Z76UrgkhG0S1VZ3/Prr5iN9HaNjrIKjuuOIUA1bHIO/ulhyKsr92BNZ5Qj3ZRxr1rRZgjHCVR8TtFzxYQhLJXfyqYTSgFDcg2f/XvBQ3KGZfdpsXo078MVxHyigThVKjAPnZKtGwi2fjHU1MpXmVzp5iEGY1QnUii42QfOY3nCAstTCqoFRnYFRF8NCi5wzA7ltU4/Led2efj/znZq7FjSenLCqATmLGQ1iM8lNysqMSHpNI4Y2cZ02h5txCEavQ2OSMEA0+d3Yb7LQhUPGh2NpEIaNKZA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UEMDLUT2MQdaW6xJmAXKwIFNsNOGTmkXBl8XFTsox16/pEa7Qnhm/1LWRWCTfbye+Gz9I88yYNfz2oTfTrgHRrt8X05N3bZmpFmnjsQLuUvPHnLMzEJ1Yb7hNRmnx+u65AjPEKgnOI/qXDsRywUsXjinzXvEDw+WRh1v8S8i0/Kx9/BaJPyWadFomflwO7d1WGuRr6Yy9MEZKdKWrw3TRZBDcf2K4hlZ9PulMNcGC2N6R38SChchMLgh+ZkyUJlzsrdjLVNmu8xoPjfXY0dponHjoX8PQBgS+Ve7okqpncQptOY9hk+MnQG5vWBPA6HUR4xygMG1V9Jr5nVcCwlB9Q==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com;
  • Cc: Bertrand.Marquis@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, julien@xxxxxxx
  • Delivery-date: Wed, 11 Aug 2021 10:50:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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;

> | 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?

> --- 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.

Jan




 


Rackspace

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