Re: [PATCH 21/32] Convert 'int i' to 'size_t i' in src/node_device/ files

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

 



On 07/08/2013 10:21 PM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
  src/node_device/node_device_driver.c |  6 +++---
  src/node_device/node_device_hal.c    |  9 ++++++---
  src/nodeinfo.c                       | 24 ++++++++++++------------
  3 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 1f7e0fd..c7b15e1 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -131,7 +131,7 @@ nodeNumOfDevices(virConnectPtr conn,
  {
      virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
      int ndevs = 0;
-    unsigned int i;
+    size_t i;
if (virNodeNumOfDevicesEnsureACL(conn) < 0)
          return -1;
@@ -161,7 +161,7 @@ nodeListDevices(virConnectPtr conn,
  {
      virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
      int ndevs = 0;
-    unsigned int i;
+    size_t i;
if (virNodeListDevicesEnsureACL(conn) < 0)
          return -1;
@@ -249,7 +249,7 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
                                const char *wwpn,
                                unsigned int flags)
  {
-    unsigned int i;
+    size_t i;
      virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
      virNodeDeviceObjListPtr devs = &driver->devs;
      virNodeDevCapsDefPtr cap = NULL;
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 794f923..d94767c 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -408,7 +408,8 @@ gather_capabilities(LibHalContext *ctx, const char *udi,
      char *bus_name = NULL;
      virNodeDevCapsDefPtr caps = NULL;
      char **hal_cap_names = NULL;
-    int rv, i;
+    int rv;
+    size_t i;
if (STREQ(udi, "/org/freedesktop/Hal/devices/computer")) {
          rv = gather_capability(ctx, udi, "system", &caps);
@@ -632,7 +633,8 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
  {
      LibHalContext *hal_ctx = NULL;
      char **udi = NULL;
-    int num_devs, i;
+    int num_devs;
+    size_t i;
      int ret = -1;
      DBusConnection *sysbus;
      DBusError err;
@@ -750,7 +752,8 @@ nodeStateReload(void)
  {
      DBusError err;
      char **udi = NULL;
-    int num_devs, i;
+    int num_devs;
+    size_t i;
      LibHalContext *hal_ctx;
VIR_INFO("Reloading HAL device state");
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index a50f892..d48c7ed 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -157,7 +157,7 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu)
      char *path;
      FILE *pathfp;
      char str[1024];
-    int i;
+    size_t i;
if (virAsprintf(&path, "%s/cpu%u/topology/thread_siblings",
                      dir, cpu) < 0) {
@@ -221,7 +221,7 @@ virNodeParseSocket(const char *dir, unsigned int cpu)
  static int
  CPU_COUNT(cpu_set_t *set)
  {
-    int i, count = 0;
+    size_t i, count = 0;
for (i = 0; i < CPU_SETSIZE; i++)
          if (CPU_ISSET(i, set))
@@ -251,7 +251,7 @@ virNodeParseNode(const char *node,
      int sock;
      cpu_set_t *core_maps = NULL;
      int core;
-    int i;
+    size_t i;
      int siblings;
      unsigned int cpu;
      int online;
@@ -635,7 +635,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
          char *buf = line;
if (STRPREFIX(buf, cpu_header)) { /* aka logical CPU time */
-            int i;
+            size_t i;
if (sscanf(buf,
                         "%*s %llu %llu %llu %llu %llu" // user ~ iowait
@@ -709,7 +709,7 @@ int linuxNodeGetMemoryStats(FILE *meminfo,
                              int *nparams)
  {
      int ret = -1;
-    int i = 0, j = 0, k = 0;
+    size_t i = 0, j = 0, k = 0;
      int found = 0;
      int nr_param;
      char line[1024];
@@ -1041,7 +1041,7 @@ nodeGetCPUCount(void)
       * will be consecutive.
       */
      char *cpupath = NULL;
-    int i = 0;
+    size_t i = 0;

linuxParseCPUmax can return -1 to i.

Guannan

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]