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

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


  • To: <wei.chen@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>, <jbeulich@xxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Wed, 11 Aug 2021 18:23:44 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); 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=XbmZt/3Qnc8x9mhpmsFguDqJamcughb+6Xb0Z1N6iV0=; b=Bc/XctFxJY111BIGhVY0YdrUtf2umPSqft5wkTTBRTet/8IznD2wnGBi8I+oTDQbAV7sAErPTbpQx6tuCO8ot92sK41blXWZVRl70whRMXyGniUUPKi+cPer2jEHz62wY96CKBIfSbGpkf77vfZjkD7qgU9YmrqAgs+FwR6/YWwjVslhVjkm+HQRSar9SpsEwpAVm99CYVhxIe7INkQxm1X08aAyE/8X3yh4AtqqFjNZTfCKiiTahQNXQVEfohb1s0+0yUGpgqUeP8h3glB3C+yNABTRKaclY0KcLh/NdZvgTSMfOYF7lkz51OESFXWIs5E9zunCTh5M8XP4C0r9Dg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U+aSOJkWljn8dNbM7OpivMCS/cBtjK6o/cMszEMLeqvIquURXylBvokcVqdoY6LaIeW19lPYNGYRpC9KUFnB4TIqoYAVo6RJMtVW2A0n9cr76awaR3y8KLHLHLZCje08y7K359/fTqQNfQPQd2ZaHf74p1iHFHZ5iR84U8H+IW/jlrLPk3VeEdKNoplzFHENZrcDfxbF6NB6VT3xx6Qmwar1ukbYGlwR02AWyZzFNMQQnMoboisRwgKfG1GDDLe1IKEjUqv1o7OOGUr5fpzKRl8QxQLn1/mWHaD+tGPPpJpOmvg0Jjfl1nNObbeZT6NNsnGmrdhgZVWADDO22cLFRA==
  • Cc: <Bertrand.Marquis@xxxxxxx>
  • Delivery-date: Wed, 11 Aug 2021 10:25:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

| 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;
|       |     ~~~~~~~~~~~~~^~~~~~
| 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 )
|       |                      ~~~~^~~~~~~

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
 tools/libs/util/libxlu_pci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/libs/util/libxlu_pci.c b/tools/libs/util/libxlu_pci.c
index 551d8e3aed..b38e9aab40 100644
--- 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;
-- 
2.25.1




 


Rackspace

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