[PATCH 14/32] Convert 'int i' to 'size_t i' in src/rpc/ files

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

 



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/rpc/gendispatch.pl        |  7 ++++---
 src/rpc/virnetclient.c        |  2 +-
 src/rpc/virnetclientprogram.c |  2 +-
 src/rpc/virnetserver.c        | 10 +++++-----
 src/rpc/virnetserverservice.c | 10 +++++-----
 src/rpc/virnetsocket.c        |  2 +-
 src/rpc/virnetsshsession.c    | 10 +++++-----
 src/rpc/virnettlscontext.c    |  7 ++++---
 8 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index fdf5a79..ab70c62 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -1475,7 +1475,7 @@ elsif ($mode eq "client") {
         }
 
         if ($single_ret_as_list) {
-            print "    int i;\n";
+            print "    size_t i;\n";
         }
 
         if ($call->{streamflag} ne "none") {
@@ -1594,8 +1594,9 @@ elsif ($mode eq "client") {
             print "    for (i = 0; i < ret.$single_ret_list_name.${single_ret_list_name}_len; ++i) {\n";
             print "        if (VIR_STRDUP(${single_ret_list_name}[i],\n";
             print "                       ret.$single_ret_list_name.${single_ret_list_name}_val[i]) < 0) {\n";
-            print "            for (--i; i >= 0; --i)\n";
-            print "                VIR_FREE(${single_ret_list_name}[i]);\n";
+            print "            size_t j;\n";
+            print "            for (j = 0; j < i; j++)\n";
+            print "                VIR_FREE(${single_ret_list_name}[j]);\n";
             print "\n";
             print "            goto cleanup;\n";
             print "        }\n";
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index fed2c87..b6dfb41 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -592,7 +592,7 @@ bool virNetClientHasPassFD(virNetClientPtr client)
 void virNetClientDispose(void *obj)
 {
     virNetClientPtr client = obj;
-    int i;
+    size_t i;
 
     PROBE(RPC_CLIENT_DISPOSE,
           "client=%p", client);
diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c
index 1016f55..75ff522 100644
--- a/src/rpc/virnetclientprogram.c
+++ b/src/rpc/virnetclientprogram.c
@@ -195,7 +195,7 @@ cleanup:
 static virNetClientProgramEventPtr virNetClientProgramGetEvent(virNetClientProgramPtr prog,
                                                                int procedure)
 {
-    int i;
+    size_t i;
 
     for (i = 0; i < prog->nevents; i++) {
         if (prog->events[i].proc == procedure)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 9f56b03..7642999 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -856,7 +856,7 @@ virNetServerSignalEvent(int watch,
                         void *opaque) {
     virNetServerPtr srv = opaque;
     siginfo_t siginfo;
-    int i;
+    size_t i;
 
     virObjectLock(srv);
 
@@ -1046,7 +1046,7 @@ static void virNetServerAutoShutdownTimer(int timerid ATTRIBUTE_UNUSED,
 void virNetServerUpdateServices(virNetServerPtr srv,
                                 bool enabled)
 {
-    int i;
+    size_t i;
 
     virObjectLock(srv);
     for (i = 0; i < srv->nservices; i++)
@@ -1060,7 +1060,7 @@ void virNetServerRun(virNetServerPtr srv)
 {
     int timerid = -1;
     bool timerActive = false;
-    int i;
+    size_t i;
 
     virObjectLock(srv);
 
@@ -1156,7 +1156,7 @@ void virNetServerQuit(virNetServerPtr srv)
 void virNetServerDispose(void *obj)
 {
     virNetServerPtr srv = obj;
-    int i;
+    size_t i;
 
     VIR_FORCE_CLOSE(srv->autoShutdownInhibitFd);
 
@@ -1195,7 +1195,7 @@ void virNetServerDispose(void *obj)
 
 void virNetServerClose(virNetServerPtr srv)
 {
-    int i;
+    size_t i;
 
     if (!srv)
         return;
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index baf0ebe..c8c00d1 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -158,7 +158,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
                                                   size_t nrequests_client_max)
 {
     virNetServerServicePtr svc;
-    int i;
+    size_t i;
 
     if (virNetServerServiceInitialize() < 0)
         return NULL;
@@ -220,7 +220,7 @@ virNetServerServicePtr virNetServerServiceNewFD(int fd,
                                                 size_t nrequests_client_max)
 {
     virNetServerServicePtr svc;
-    int i;
+    size_t i;
 
     if (virNetServerServiceInitialize() < 0)
         return NULL;
@@ -435,7 +435,7 @@ void virNetServerServiceSetDispatcher(virNetServerServicePtr svc,
 void virNetServerServiceDispose(void *obj)
 {
     virNetServerServicePtr svc = obj;
-    int i;
+    size_t i;
 
     for (i = 0; i < svc->nsocks; i++)
         virObjectUnref(svc->socks[i]);
@@ -449,7 +449,7 @@ void virNetServerServiceDispose(void *obj)
 void virNetServerServiceToggle(virNetServerServicePtr svc,
                                bool enabled)
 {
-    int i;
+    size_t i;
 
     for (i = 0; i < svc->nsocks; i++)
         virNetSocketUpdateIOCallback(svc->socks[i],
@@ -460,7 +460,7 @@ void virNetServerServiceToggle(virNetServerServicePtr svc,
 
 void virNetServerServiceClose(virNetServerServicePtr svc)
 {
-    int i;
+    size_t i;
 
     if (!svc)
         return;
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 27709d8..debe31f 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -223,7 +223,7 @@ int virNetSocketNewListenTCP(const char *nodename,
     struct addrinfo *ai = NULL;
     struct addrinfo hints;
     int fd = -1;
-    int i;
+    size_t i;
     int addrInUse = false;
 
     *retsocks = NULL;
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index b6aedc8..0153b04 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -114,7 +114,7 @@ struct _virNetSSHSession {
 static void
 virNetSSHSessionAuthMethodsFree(virNetSSHSessionPtr sess)
 {
-    int i;
+    size_t i;
 
     for (i = 0; i < sess->nauths; i++) {
         VIR_FREE(sess->auths[i]->username);
@@ -205,7 +205,7 @@ virNetSSHKbIntCb(const char *name ATTRIBUTE_UNUSED,
 {
     virNetSSHSessionPtr priv = *opaque;
     virConnectCredentialPtr askcred = NULL;
-    int i;
+    size_t i;
     int credtype_echo = -1;
     int credtype_noecho = -1;
     char *tmp;
@@ -294,7 +294,7 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
     virBuffer buff = VIR_BUFFER_INITIALIZER;
     virConnectCredential askKey;
     struct libssh2_knownhost *knownHostEntry = NULL;
-    int i;
+    size_t i;
     char *hostnameStr = NULL;
 
     if (sess->hostKeyVerify == VIR_NET_SSH_HOSTKEY_VERIFY_IGNORE)
@@ -585,7 +585,7 @@ virNetSSHAuthenticatePrivkey(virNetSSHSessionPtr sess,
                              virNetSSHAuthMethodPtr priv)
 {
     virConnectCredential retr_passphrase;
-    int i;
+    size_t i;
     char *errmsg;
     int ret;
 
@@ -783,7 +783,7 @@ virNetSSHAuthenticate(virNetSSHSessionPtr sess)
     bool auth_failed = false;
     char *auth_list;
     char *errmsg;
-    int i;
+    size_t i;
     int ret;
 
     if (!sess->nauths) {
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 9b43a80..02a4c29 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -287,7 +287,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
                                                bool isServer)
 {
     int status;
-    int i;
+    size_t i;
     unsigned int purposeCritical;
     unsigned int critical;
     char *buffer = NULL;
@@ -300,7 +300,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
         status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer, &size, NULL);
 
         if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
-            VIR_DEBUG("No key purpose data available at slot %d", i);
+            VIR_DEBUG("No key purpose data available at slot %zu", i);
 
             /* If there is no data at all, then we must allow client/server to pass */
             if (i == 0)
@@ -954,7 +954,8 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
     int ret;
     unsigned int status;
     const gnutls_datum_t *certs;
-    unsigned int nCerts, i;
+    unsigned int nCerts;
+    size_t i;
     char dname[256];
     char *dnameptr = dname;
     size_t dnamesize = sizeof(dname);
-- 
1.8.1.4

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