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

[libvirt] [PATCH 31/32] Convert 'int i' to 'size_t i' in examples/ files



From: "Daniel P. Berrange" <berrange redhat com>

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 redhat com>
---
 examples/domain-events/events-c/event-test.c |  2 +-
 examples/domsuspend/suspend.c                | 14 ++++++++------
 examples/openauth/openauth.c                 |  2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index 1b425fb..e9b3881 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -320,7 +320,7 @@ static int myDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
                                          virDomainEventGraphicsSubjectPtr subject,
                                          void *opaque ATTRIBUTE_UNUSED)
 {
-    int i;
+    size_t i;
     printf("%s EVENT: Domain %s(%d) graphics ", __func__, virDomainGetName(dom),
            virDomainGetID(dom));
 
diff --git a/examples/domsuspend/suspend.c b/examples/domsuspend/suspend.c
index d9f56bb..6a0f5c9 100644
--- a/examples/domsuspend/suspend.c
+++ b/examples/domsuspend/suspend.c
@@ -107,15 +107,17 @@ int main(int argc, char **argv) {
         id = atoi(argv[1]);
     }
     if (id == 0) {
-        int i, j, ids[10];
-        i = virConnectListDomains(conn, &ids[0], 10);
-        if (i < 0) {
+        int n;
+        size_t i;
+        int ids[10];
+        n = virConnectListDomains(conn, &ids[0], 10);
+        if (n < 0) {
             fprintf(stderr, "Failed to list the domains\n");
             goto error;
         }
-        for (j = 0; j < i; j++) {
-            if (ids[j] != 0) {
-                id = ids[j];
+        for (i = 0; i < n; i++) {
+            if (ids[i] != 0) {
+                id = ids[i];
                 break;
             }
         }
diff --git a/examples/openauth/openauth.c b/examples/openauth/openauth.c
index 628451c..dd44ee9 100644
--- a/examples/openauth/openauth.c
+++ b/examples/openauth/openauth.c
@@ -161,7 +161,7 @@ typedef struct _AuthData AuthData;
 static int
 authCallback(virConnectCredentialPtr cred, unsigned int ncred, void *cbdata)
 {
-    int i;
+    size_t i;
     AuthData *authData = cbdata;
 
     /* libvirt might request multiple credentials in a single call.
-- 
1.8.1.4


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