Skip to contentSkip to conversation

libxl: Avoid a variable named 'stat'

PATCH New George Dunlap 1 participant 1 message Aug 24, 2017 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 libxl: Avoid a variable named 'stat'

Forwarding to the correct address...
-G

-------- Forwarded Message --------
Subject: [PATCH] libxl: Avoid a variable named 'stat'
Date: Thu, 24 Aug 2017 12:34:13 +0100
From: George Dunlap <[email protected]>
To: [email protected]
CC: George Dunlap <[email protected]>, Daniel P . Berrange <[email protected]>, Jim Fehlig <[email protected]>, [email protected]

Using a variable named 'stat' clashes with the system function 'stat()' causing compiler warnings on some platforms:

libxl/libxl_driver.c: In function 'libxlDomainBlockStatsVBD':
libxl/libxl_driver.c:5387: error: declaration of 'stat' shadows a global declaration [-Wshadow]
/usr/include/sys/stat.h:455: error: shadowed declaration is here [-Wshadow]

---
CC: Daniel P. Berrange <[email protected]>
CC: Jim Fehlig <[email protected]>
CC: [email protected]
CC: [email protected]

---
 src/libxl/libxl_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/libxl/libxl_driver.c +3 -3
index c261e2155..4c7775358 100644
@@ -5374,7 +5374,7 @@ libxlDomainBlockStatsVBD(virDomainObjPtr vm,
     int devno = libxlDiskPathToID(dev);
     int size;
     char *path, *name, *val;
-    unsigned long long stat;
+    unsigned long long status;
      path = name = val = NULL;
     if (devno < 0) {
@@ -5401,12 +5401,12 @@ libxlDomainBlockStatsVBD(virDomainObjPtr vm,
 # define LIBXL_SET_VBDSTAT(FIELD, VAR, MUL)           \
     if ((virAsprintf(&name, "%s/"FIELD, path) < 0) || \
         (virFileReadAll(name, 256, &val) < 0) ||      \
-        (sscanf(val, "%llu", &stat) != 1)) {          \
+        (sscanf(val, "%llu", &status) != 1)) {          \
         virReportError(VIR_ERR_OPERATION_FAILED,      \
                        _("cannot read %s"), name);    \
         goto cleanup;                                 \
     }                                                 \
-    VAR += (stat * MUL);                              \
+    VAR += (status * MUL);                              \
     VIR_FREE(name);                                   \
     VIR_FREE(val);
 -- 2.14.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel