Blame SOURCES/Fix-mismatched-sign-comparisons.patch

1f3433
From a68b8b418bfc42c628fee605cc52dca92ab410c9 Mon Sep 17 00:00:00 2001
1f3433
From: Robbie Harwood <rharwood@redhat.com>
1f3433
Date: Wed, 15 Mar 2017 14:52:08 -0400
1f3433
Subject: [PATCH] Fix mismatched sign comparisons
1f3433
1f3433
We are c99, so also migrate to `for`-loop initializers where possible for
1f3433
clarity.
1f3433
1f3433
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
1f3433
Reviewed-by: Simo Sorce <simo@redhat.com>
1f3433
Merges: #173
1f3433
(cherry picked from commit 377e92c7ead312c530b233a1e023493ecde033d6)
1f3433
---
68bf20
 proxy/src/client/gpm_acquire_cred.c          | 11 ++-----
68bf20
 proxy/src/client/gpm_common.c                |  4 +--
68bf20
 proxy/src/client/gpm_import_and_canon_name.c |  7 ++---
68bf20
 proxy/src/client/gpm_indicate_mechs.c        | 33 +++++++++-----------
68bf20
 proxy/src/gp_common.h                        |  3 +-
68bf20
 proxy/src/gp_config.c                        |  9 ++----
68bf20
 proxy/src/gp_conv.c                          |  6 ++--
68bf20
 proxy/src/gp_creds.c                         |  3 +-
68bf20
 proxy/src/gp_export.c                        |  9 ++----
68bf20
 proxy/src/gp_rpc_acquire_cred.c              |  5 ++-
68bf20
 proxy/src/gp_rpc_debug.c                     | 26 +++++++--------
68bf20
 proxy/src/gp_rpc_indicate_mechs.c            | 15 +++------
68bf20
 proxy/src/gp_socket.c                        |  4 +--
68bf20
 proxy/src/gp_util.c                          |  4 +--
68bf20
 proxy/tests/t_utils.c                        |  4 +--
1f3433
 15 files changed, 58 insertions(+), 85 deletions(-)
1f3433
1f3433
diff --git a/proxy/src/client/gpm_acquire_cred.c b/proxy/src/client/gpm_acquire_cred.c
1f3433
index 632973d..8e30e1d 100644
1f3433
--- a/proxy/src/client/gpm_acquire_cred.c
1f3433
+++ b/proxy/src/client/gpm_acquire_cred.c
1f3433
@@ -6,8 +6,6 @@ static int gpmint_cred_to_actual_mechs(gssx_cred *c, gss_OID_set *a)
1f3433
 {
1f3433
     gssx_cred_element *e;
1f3433
     gss_OID_set m = GSS_C_NO_OID_SET;
1f3433
-    int i;
1f3433
-
1f3433
 
1f3433
     if (c->elements.elements_len) {
1f3433
 
1f3433
@@ -22,7 +20,7 @@ static int gpmint_cred_to_actual_mechs(gssx_cred *c, gss_OID_set *a)
1f3433
             return ENOMEM;
1f3433
         }
1f3433
 
1f3433
-        for (i = 0; i < c->elements.elements_len; i++) {
1f3433
+        for (unsigned i = 0; i < c->elements.elements_len; i++) {
1f3433
             e = &c->elements.elements_val[i];
1f3433
 
1f3433
             m->elements[i].elements = gp_memdup(e->mech.octet_string_val,
1f3433
@@ -280,7 +278,6 @@ OM_uint32 gpm_inquire_cred(OM_uint32 *minor_status,
1f3433
     uint32_t ret_maj = GSS_S_COMPLETE;
1f3433
     uint32_t life;
1f3433
     int cu;
1f3433
-    int i;
1f3433
 
1f3433
     if (!cred) {
1f3433
         *minor_status = 0;
1f3433
@@ -308,8 +305,7 @@ OM_uint32 gpm_inquire_cred(OM_uint32 *minor_status,
1f3433
     life = GSS_C_INDEFINITE;
1f3433
     cu = -1;
1f3433
 
1f3433
-    for (i = 0; i < cred->elements.elements_len; i++) {
1f3433
-
1f3433
+    for (unsigned i = 0; i < cred->elements.elements_len; i++) {
1f3433
         e = &cred->elements.elements_val[i];
1f3433
 
1f3433
         switch (e->cred_usage) {
1f3433
@@ -402,7 +398,7 @@ OM_uint32 gpm_inquire_cred_by_mech(OM_uint32 *minor_status,
1f3433
     gss_OID_desc tmp_oid;
1f3433
     uint32_t ret_min = 0;
1f3433
     uint32_t ret_maj = GSS_S_COMPLETE;
1f3433
-    int i;
1f3433
+    unsigned i;
1f3433
 
1f3433
     if (!cred) {
1f3433
         *minor_status = 0;
1f3433
@@ -414,7 +410,6 @@ OM_uint32 gpm_inquire_cred_by_mech(OM_uint32 *minor_status,
1f3433
     }
1f3433
 
1f3433
     for (i = 0; i < cred->elements.elements_len; i++) {
1f3433
-
1f3433
         e = &cred->elements.elements_val[i];
1f3433
         gp_conv_gssx_to_oid(&e->mech, &tmp_oid);
1f3433
         if (!gss_oid_equal(&tmp_oid, mech_type)) {
1f3433
diff --git a/proxy/src/client/gpm_common.c b/proxy/src/client/gpm_common.c
1f3433
index 030765a..8c96986 100644
1f3433
--- a/proxy/src/client/gpm_common.c
1f3433
+++ b/proxy/src/client/gpm_common.c
1f3433
@@ -166,7 +166,7 @@ static int gpm_send_buffer(struct gpm_ctx *gpmctx,
1f3433
                            char *buffer, uint32_t length)
1f3433
 {
1f3433
     uint32_t size;
1f3433
-    size_t wn;
1f3433
+    ssize_t wn;
1f3433
     size_t pos;
1f3433
     bool retry;
1f3433
     int ret;
1f3433
@@ -232,7 +232,7 @@ static int gpm_recv_buffer(struct gpm_ctx *gpmctx,
1f3433
                            char *buffer, uint32_t *length)
1f3433
 {
1f3433
     uint32_t size;
1f3433
-    size_t rn;
1f3433
+    ssize_t rn;
1f3433
     size_t pos;
1f3433
     int ret;
1f3433
 
1f3433
diff --git a/proxy/src/client/gpm_import_and_canon_name.c b/proxy/src/client/gpm_import_and_canon_name.c
1f3433
index 83d0736..70149a3 100644
1f3433
--- a/proxy/src/client/gpm_import_and_canon_name.c
1f3433
+++ b/proxy/src/client/gpm_import_and_canon_name.c
1f3433
@@ -275,7 +275,6 @@ OM_uint32 gpm_inquire_name(OM_uint32 *minor_status,
1f3433
 {
1f3433
     gss_buffer_set_t xattrs = GSS_C_NO_BUFFER_SET;
1f3433
     int ret;
1f3433
-    int i;
1f3433
 
1f3433
     *minor_status = 0;
1f3433
 
1f3433
@@ -306,13 +305,13 @@ OM_uint32 gpm_inquire_name(OM_uint32 *minor_status,
1f3433
             *minor_status = ENOMEM;
1f3433
             return GSS_S_FAILURE;
1f3433
         }
1f3433
-        for (i = 0; i < xattrs->count; i++) {
1f3433
+        for (unsigned i = 0; i < xattrs->count; i++) {
1f3433
             ret = gp_copy_gssx_to_buffer(
1f3433
                         &name->name_attributes.name_attributes_val[i].attr,
1f3433
                         &xattrs->elements[i]);
1f3433
             if (ret) {
1f3433
-                for (--i; i >= 0; i--) {
1f3433
-                    free(xattrs->elements[i].value);
1f3433
+                for (; i > 0; i--) {
1f3433
+                    free(xattrs->elements[i-1].value);
1f3433
                 }
1f3433
                 free(xattrs->elements);
1f3433
                 free(xattrs);
1f3433
diff --git a/proxy/src/client/gpm_indicate_mechs.c b/proxy/src/client/gpm_indicate_mechs.c
1f3433
index d4df923..b019a96 100644
1f3433
--- a/proxy/src/client/gpm_indicate_mechs.c
1f3433
+++ b/proxy/src/client/gpm_indicate_mechs.c
1f3433
@@ -51,7 +51,6 @@ static uint32_t gpm_copy_gss_OID_set(uint32_t *minor_status,
1f3433
     gss_OID_set n;
1f3433
     uint32_t ret_maj;
1f3433
     uint32_t ret_min;
1f3433
-    int i;
1f3433
 
1f3433
     ret_maj = gss_create_empty_oid_set(&ret_min, &n);
1f3433
     if (ret_maj) {
1f3433
@@ -59,7 +58,7 @@ static uint32_t gpm_copy_gss_OID_set(uint32_t *minor_status,
1f3433
         return ret_maj;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < oldset->count; i++) {
1f3433
+    for (size_t i = 0; i < oldset->count; i++) {
1f3433
         ret_maj = gss_add_oid_set_member(&ret_min, &oldset->elements[i], &n);
1f3433
         if (ret_maj) {
1f3433
             *minor_status = ret_min;
1f3433
@@ -124,7 +123,6 @@ static void gpmint_indicate_mechs(void)
1f3433
     uint32_t ret_min;
1f3433
     uint32_t ret_maj = 0;
1f3433
     int ret = 0;
1f3433
-    int i;
1f3433
 
1f3433
     memset(arg, 0, sizeof(gssx_arg_indicate_mechs));
1f3433
     memset(res, 0, sizeof(gssx_res_indicate_mechs));
1f3433
@@ -158,7 +156,7 @@ static void gpmint_indicate_mechs(void)
1f3433
         goto done;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < res->mechs.mechs_len; i++) {
1f3433
+    for (unsigned i = 0; i < res->mechs.mechs_len; i++) {
1f3433
         mi = &res->mechs.mechs_val[i];
1f3433
         gi = &global_mechs.info[i];
1f3433
 
1f3433
@@ -222,7 +220,7 @@ static void gpmint_indicate_mechs(void)
1f3433
         goto done;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < res->mech_attr_descs.mech_attr_descs_len; i++) {
1f3433
+    for (unsigned i = 0; i < res->mech_attr_descs.mech_attr_descs_len; i++) {
1f3433
         ma = &res->mech_attr_descs.mech_attr_descs_val[i];
1f3433
         ga = &global_mechs.desc[i];
1f3433
 
1f3433
@@ -249,7 +247,7 @@ static void gpmint_indicate_mechs(void)
1f3433
 
1f3433
 done:
1f3433
     if (ret || ret_maj) {
1f3433
-        for (i = 0; i < global_mechs.desc_len; i++) {
1f3433
+        for (unsigned i = 0; i < global_mechs.desc_len; i++) {
1f3433
             ga = &global_mechs.desc[i];
1f3433
             gss_release_oid(&discard, &ga->attr);
1f3433
             gss_release_buffer(&discard, ga->name);
1f3433
@@ -258,7 +256,7 @@ done:
1f3433
         }
1f3433
         free(global_mechs.desc);
1f3433
         global_mechs.desc = NULL;
1f3433
-        for (i = 0; i < global_mechs.info_len; i++) {
1f3433
+        for (unsigned i = 0; i < global_mechs.info_len; i++) {
1f3433
             gi = &global_mechs.info[i];
1f3433
             gss_release_oid(&discard, &gi->mech);
1f3433
             gss_release_oid_set(&discard, &gi->name_types);
1f3433
@@ -335,7 +333,6 @@ OM_uint32 gpm_inquire_names_for_mech(OM_uint32 *minor_status,
1f3433
 {
1f3433
     uint32_t ret_min;
1f3433
     uint32_t ret_maj;
1f3433
-    int i;
1f3433
 
1f3433
     if (!minor_status) {
1f3433
         return GSS_S_CALL_INACCESSIBLE_WRITE;
1f3433
@@ -351,7 +348,7 @@ OM_uint32 gpm_inquire_names_for_mech(OM_uint32 *minor_status,
1f3433
         return GSS_S_FAILURE;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < global_mechs.info_len; i++) {
1f3433
+    for (unsigned i = 0; i < global_mechs.info_len; i++) {
1f3433
         if (!gpm_equal_oids(global_mechs.info[i].mech, mech_type)) {
1f3433
             continue;
1f3433
         }
1f3433
@@ -375,7 +372,6 @@ OM_uint32 gpm_inquire_mechs_for_name(OM_uint32 *minor_status,
1f3433
     uint32_t discard;
1f3433
     gss_OID name_type = GSS_C_NO_OID;
1f3433
     int present;
1f3433
-    int i;
1f3433
 
1f3433
     if (!minor_status) {
1f3433
         return GSS_S_CALL_INACCESSIBLE_WRITE;
1f3433
@@ -402,7 +398,7 @@ OM_uint32 gpm_inquire_mechs_for_name(OM_uint32 *minor_status,
1f3433
         goto done;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < global_mechs.info_len; i++) {
1f3433
+    for (unsigned i = 0; i < global_mechs.info_len; i++) {
1f3433
         ret_maj = gss_test_oid_set_member(&ret_min, name_type,
1f3433
                                           global_mechs.info[i].name_types,
1f3433
                                           &present);
1f3433
@@ -439,7 +435,6 @@ OM_uint32 gpm_inquire_attrs_for_mech(OM_uint32 *minor_status,
1f3433
     uint32_t ret_min;
1f3433
     uint32_t ret_maj;
1f3433
     uint32_t discard;
1f3433
-    int i;
1f3433
 
1f3433
     if (!minor_status) {
1f3433
         return GSS_S_CALL_INACCESSIBLE_WRITE;
1f3433
@@ -451,7 +446,7 @@ OM_uint32 gpm_inquire_attrs_for_mech(OM_uint32 *minor_status,
1f3433
         return GSS_S_FAILURE;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < global_mechs.info_len; i++) {
1f3433
+    for (unsigned i = 0; i < global_mechs.info_len; i++) {
1f3433
         if (!gpm_equal_oids(global_mechs.info[i].mech, mech)) {
1f3433
             continue;
1f3433
         }
1f3433
@@ -495,7 +490,6 @@ OM_uint32 gpm_inquire_saslname_for_mech(OM_uint32 *minor_status,
1f3433
     uint32_t ret_min;
1f3433
     uint32_t ret_maj;
1f3433
     uint32_t discard;
1f3433
-    int i;
1f3433
 
1f3433
     if (!minor_status) {
1f3433
         return GSS_S_CALL_INACCESSIBLE_WRITE;
1f3433
@@ -511,7 +505,7 @@ OM_uint32 gpm_inquire_saslname_for_mech(OM_uint32 *minor_status,
1f3433
         return GSS_S_FAILURE;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < global_mechs.info_len; i++) {
1f3433
+    for (unsigned i = 0; i < global_mechs.info_len; i++) {
1f3433
         if (!gpm_equal_oids(global_mechs.info[i].mech, desired_mech)) {
1f3433
             continue;
1f3433
         }
1f3433
@@ -554,7 +548,6 @@ OM_uint32 gpm_display_mech_attr(OM_uint32 *minor_status,
1f3433
     uint32_t ret_min;
1f3433
     uint32_t ret_maj;
1f3433
     uint32_t discard;
1f3433
-    int i;
1f3433
 
1f3433
     if (!minor_status) {
1f3433
         return GSS_S_CALL_INACCESSIBLE_WRITE;
1f3433
@@ -570,7 +563,7 @@ OM_uint32 gpm_display_mech_attr(OM_uint32 *minor_status,
1f3433
         return GSS_S_FAILURE;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < global_mechs.desc_len; i++) {
1f3433
+    for (unsigned i = 0; i < global_mechs.desc_len; i++) {
1f3433
         if (!gpm_equal_oids(global_mechs.desc[i].attr, mech_attr)) {
1f3433
             continue;
1f3433
         }
1f3433
@@ -614,7 +607,6 @@ OM_uint32 gpm_indicate_mechs_by_attrs(OM_uint32 *minor_status,
1f3433
     uint32_t ret_maj;
1f3433
     uint32_t discard;
1f3433
     int present;
1f3433
-    int i, j;
1f3433
 
1f3433
     if (!minor_status) {
1f3433
         return GSS_S_CALL_INACCESSIBLE_WRITE;
1f3433
@@ -636,8 +628,9 @@ OM_uint32 gpm_indicate_mechs_by_attrs(OM_uint32 *minor_status,
1f3433
         return ret_maj;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < global_mechs.info_len; i++) {
1f3433
+    for (unsigned i = 0; i < global_mechs.info_len; i++) {
1f3433
         if (desired_mech_attrs != GSS_C_NO_OID_SET) {
1f3433
+            unsigned j;
1f3433
             for (j = 0; j < desired_mech_attrs->count; j++) {
1f3433
                 ret_maj = gss_test_oid_set_member(&ret_min,
1f3433
                                             &desired_mech_attrs->elements[j],
1f3433
@@ -657,6 +650,7 @@ OM_uint32 gpm_indicate_mechs_by_attrs(OM_uint32 *minor_status,
1f3433
             }
1f3433
         }
1f3433
         if (except_mech_attrs != GSS_C_NO_OID_SET) {
1f3433
+            unsigned j;
1f3433
             for (j = 0; j < except_mech_attrs->count; j++) {
1f3433
                 ret_maj = gss_test_oid_set_member(&ret_min,
1f3433
                                             &except_mech_attrs->elements[j],
1f3433
@@ -676,6 +670,7 @@ OM_uint32 gpm_indicate_mechs_by_attrs(OM_uint32 *minor_status,
1f3433
             }
1f3433
         }
1f3433
         if (critical_mech_attrs != GSS_C_NO_OID_SET) {
1f3433
+            unsigned j;
1f3433
             for (j = 0; j < critical_mech_attrs->count; j++) {
1f3433
                 ret_maj = gss_test_oid_set_member(&ret_min,
1f3433
                                     &critical_mech_attrs->elements[j],
1f3433
diff --git a/proxy/src/gp_common.h b/proxy/src/gp_common.h
1f3433
index edc23b4..4f76e58 100644
1f3433
--- a/proxy/src/gp_common.h
1f3433
+++ b/proxy/src/gp_common.h
1f3433
@@ -104,9 +104,8 @@ union gp_rpc_res {
1f3433
 #define gp_options_find(res, opts, name, len) \
1f3433
 do { \
1f3433
     struct gssx_option *_v; \
1f3433
-    int _o; \
1f3433
     res = NULL; \
1f3433
-    for (_o = 0; _o < opts.options_len; _o++) { \
1f3433
+    for (unsigned _o = 0; _o < opts.options_len; _o++) { \
1f3433
         _v = &opts.options_val[_o]; \
1f3433
         if (gp_option_name_match(_v, name, len)) { \
1f3433
             res = _v; \
1f3433
diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c
1f3433
index 5c1ca02..a671333 100644
1f3433
--- a/proxy/src/gp_config.c
1f3433
+++ b/proxy/src/gp_config.c
1f3433
@@ -57,11 +57,9 @@ static void free_str_array(const char ***a, int *count)
1f3433
 
1f3433
 void free_cred_store_elements(gss_key_value_set_desc *cs)
1f3433
 {
1f3433
-    int i;
1f3433
-
1f3433
     if (!cs->elements) return;
1f3433
 
1f3433
-    for (i = 0; i < cs->count; i++) {
1f3433
+    for (unsigned i = 0; i < cs->count; i++) {
1f3433
         safefree(cs->elements[i].key);
1f3433
         safefree(cs->elements[i].value);
1f3433
     }
1f3433
@@ -146,7 +144,7 @@ static int get_krb5_mech_cfg(struct gp_service *svc,
1f3433
                                      &count, &strings);
1f3433
     if (ret == 0) {
1f3433
         const char *p;
1f3433
-        size_t len;
1f3433
+        ssize_t len;
1f3433
         char *key;
1f3433
 
1f3433
         svc->krb5.store.elements =
1f3433
@@ -698,7 +696,6 @@ struct gp_creds_handle *gp_service_get_creds_handle(struct gp_service *svc)
1f3433
 void free_config(struct gp_config **cfg)
1f3433
 {
1f3433
     struct gp_config *config = *cfg;
1f3433
-    uint32_t i;
1f3433
 
1f3433
     if (!config) {
1f3433
         return;
1f3433
@@ -709,7 +706,7 @@ void free_config(struct gp_config **cfg)
1f3433
     free(config->socket_name);
1f3433
     free(config->proxy_user);
1f3433
 
1f3433
-    for (i=0; i < config->num_svcs; i++) {
1f3433
+    for (int i = 0; i < config->num_svcs; i++) {
1f3433
         gp_service_free(config->svcs[i]);
1f3433
         safefree(config->svcs[i]);
1f3433
     }
1f3433
diff --git a/proxy/src/gp_conv.c b/proxy/src/gp_conv.c
1f3433
index 71d6d9d..b874b06 100644
1f3433
--- a/proxy/src/gp_conv.c
1f3433
+++ b/proxy/src/gp_conv.c
1f3433
@@ -599,7 +599,6 @@ done:
1f3433
 int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out)
1f3433
 {
1f3433
     gss_OID_set o;
1f3433
-    int i;
1f3433
 
1f3433
     if (in->gssx_OID_set_len == 0) {
1f3433
         *out = GSS_C_NO_OID_SET;
1f3433
@@ -618,7 +617,7 @@ int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out)
1f3433
         return ENOMEM;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < o->count; i++) {
1f3433
+    for (size_t i = 0; i < o->count; i++) {
1f3433
         o->elements[i].elements =
1f3433
                         gp_memdup(in->gssx_OID_set_val[i].octet_string_val,
1f3433
                                   in->gssx_OID_set_val[i].octet_string_len);
1f3433
@@ -641,7 +640,6 @@ int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out)
1f3433
 int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out)
1f3433
 {
1f3433
     int ret;
1f3433
-    int i;
1f3433
 
1f3433
     if (in->count == 0) {
1f3433
         return 0;
1f3433
@@ -653,7 +651,7 @@ int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out)
1f3433
         return ENOMEM;
1f3433
     }
1f3433
 
1f3433
-    for (i = 0; i < in->count; i++) {
1f3433
+    for (size_t i = 0; i < in->count; i++) {
1f3433
         ret = gp_conv_octet_string(in->elements[i].length,
1f3433
                                    in->elements[i].elements,
1f3433
                                    &out->gssx_OID_set_val[i]);
1f3433
diff --git a/proxy/src/gp_creds.c b/proxy/src/gp_creds.c
1f3433
index 6570b06..e05ad01 100644
1f3433
--- a/proxy/src/gp_creds.c
1f3433
+++ b/proxy/src/gp_creds.c
1f3433
@@ -312,7 +312,6 @@ static int gp_get_cred_environment(struct gp_call_ctx *gpcall,
1f3433
     int k_num = -1;
1f3433
     int ck_num = -1;
1f3433
     int cc_num = -1;
1f3433
-    int d;
1f3433
 
1f3433
     memset(cs, 0, sizeof(gss_key_value_set_desc));
1f3433
 
1f3433
@@ -419,7 +418,7 @@ static int gp_get_cred_environment(struct gp_call_ctx *gpcall,
1f3433
         ret = ENOMEM;
1f3433
         goto done;
1f3433
     }
1f3433
-    for (d = 0; d < svc->krb5.store.count; d++) {
1f3433
+    for (unsigned d = 0; d < svc->krb5.store.count; d++) {
1f3433
         if (strcmp(svc->krb5.store.elements[d].key, "client_keytab") == 0) {
1f3433
             ck_num = cs->count;
1f3433
         } else if (strcmp(svc->krb5.store.elements[d].key, "keytab") == 0) {
1f3433
diff --git a/proxy/src/gp_export.c b/proxy/src/gp_export.c
1f3433
index 12b8d5f..3a927c9 100644
1f3433
--- a/proxy/src/gp_export.c
1f3433
+++ b/proxy/src/gp_export.c
1f3433
@@ -288,7 +288,6 @@ uint32_t gp_export_gssx_cred(uint32_t *min, struct gp_call_ctx *gpcall,
1f3433
     uint32_t acceptor_lifetime = 0;
1f3433
     struct gssx_cred_element *el;
1f3433
     int ret;
1f3433
-    int i, j;
1f3433
     struct gp_creds_handle *handle = NULL;
1f3433
     gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
1f3433
 
1f3433
@@ -314,8 +313,7 @@ uint32_t gp_export_gssx_cred(uint32_t *min, struct gp_call_ctx *gpcall,
1f3433
     }
1f3433
     out->elements.elements_len = mechanisms->count;
1f3433
 
1f3433
-    for (i = 0, j = 0; i < mechanisms->count; i++, j++) {
1f3433
-
1f3433
+    for (unsigned i = 0, j = 0; i < mechanisms->count; i++, j++) {
1f3433
         el = &out->elements.elements_val[j];
1f3433
 
1f3433
         ret_maj = gss_inquire_cred_by_mech(&ret_min, *in,
1f3433
@@ -399,11 +397,10 @@ static void gp_set_cred_options(gssx_cred *cred, gss_cred_id_t gss_cred)
1f3433
     krb5_enctype *ktypes;
1f3433
     bool no_ci_flags = false;
1f3433
     uint32_t maj, min;
1f3433
-    int i, j;
1f3433
 
1f3433
-    for (i = 0; i < cred->elements.elements_len; i++) {
1f3433
+    for (unsigned i = 0; i < cred->elements.elements_len; i++) {
1f3433
         ce = &cred->elements.elements_val[i];
1f3433
-        for (j = 0; j < ce->options.options_len; j++) {
1f3433
+        for (unsigned j = 0; j < ce->options.options_len; j++) {
1f3433
             op = &ce->options.options_val[j];
1f3433
             if ((op->option.octet_string_len ==
1f3433
                     sizeof(KRB5_SET_ALLOWED_ENCTYPE)) &&
1f3433
diff --git a/proxy/src/gp_rpc_acquire_cred.c b/proxy/src/gp_rpc_acquire_cred.c
1f3433
index e9c7d56..fcb4fbe 100644
1f3433
--- a/proxy/src/gp_rpc_acquire_cred.c
1f3433
+++ b/proxy/src/gp_rpc_acquire_cred.c
1f3433
@@ -20,7 +20,6 @@ int gp_acquire_cred(struct gp_call_ctx *gpcall,
1f3433
     gss_cred_id_t *add_out_cred = NULL;
1f3433
     int acquire_type = ACQ_NORMAL;
1f3433
     int ret;
1f3433
-    int i;
1f3433
 
1f3433
     aca = &arg->acquire_cred;
1f3433
     acr = &res->acquire_cred;
1f3433
@@ -63,7 +62,7 @@ int gp_acquire_cred(struct gp_call_ctx *gpcall,
1f3433
             goto done;
1f3433
         }
1f3433
 
1f3433
-        for (i = 0; i < desired_mechs->count; i++) {
1f3433
+        for (unsigned i = 0; i < desired_mechs->count; i++) {
1f3433
             desired_mech = &desired_mechs->elements[i];
1f3433
 
1f3433
             if (!gp_creds_allowed_mech(gpcall, desired_mech)) {
1f3433
@@ -93,7 +92,7 @@ int gp_acquire_cred(struct gp_call_ctx *gpcall,
1f3433
 
1f3433
     cred_usage = gp_conv_gssx_to_cred_usage(aca->cred_usage);
1f3433
 
1f3433
-    for (i = 0; i < use_mechs->count; i++) {
1f3433
+    for (unsigned i = 0; i < use_mechs->count; i++) {
1f3433
         desired_mech = &use_mechs->elements[i];
1f3433
         /* this should really be folded into an extended
1f3433
          * gss_add_cred in gssapi that can accept a set of URIs
1f3433
diff --git a/proxy/src/gp_rpc_debug.c b/proxy/src/gp_rpc_debug.c
1f3433
index 2e2c050..a814448 100644
1f3433
--- a/proxy/src/gp_rpc_debug.c
1f3433
+++ b/proxy/src/gp_rpc_debug.c
1f3433
@@ -19,7 +19,7 @@ void gpdbg_octet_string(octet_string *x)
1f3433
         }
1f3433
         fprintf(stderr, "... ] ");
1f3433
     } else {
1f3433
-        for (int i = 0; i < x->octet_string_len; i++) {
1f3433
+        for (unsigned i = 0; i < x->octet_string_len; i++) {
1f3433
             fprintf(stderr, "%x", x->octet_string_val[i]);
1f3433
         }
1f3433
         fprintf(stderr, " ] ");
1f3433
@@ -55,7 +55,7 @@ void gpdbg_gssx_OID(gssx_OID *x)
1f3433
 void gpdbg_gssx_OID_set(gssx_OID_set *x)
1f3433
 {
1f3433
     gp_debug_printf("{ ");
1f3433
-    for (int i = 0; i < x->gssx_OID_set_len; i++) {
1f3433
+    for (unsigned i = 0; i < x->gssx_OID_set_len; i++) {
1f3433
         gpdbg_gssx_OID(&x->gssx_OID_set_val[i]);
1f3433
     }
1f3433
     gp_debug_printf("} ");
1f3433
@@ -90,7 +90,7 @@ void gpdbg_gssx_option(gssx_option *x)
1f3433
 #define gpdbg_extensions(x) do { \
1f3433
     if ((x)->extensions.extensions_len > 0) { \
1f3433
         gp_debug_printf("[ "); \
1f3433
-        for (int i = 0; i < (x)->extensions.extensions_len; i++) { \
1f3433
+        for (unsigned i = 0; i < (x)->extensions.extensions_len; i++) { \
1f3433
             gpdbg_gssx_option(&(x)->extensions.extensions_val[i]); \
1f3433
         } \
1f3433
         gp_debug_printf("] "); \
1f3433
@@ -100,7 +100,7 @@ void gpdbg_gssx_option(gssx_option *x)
1f3433
 #define gpdbg_options(x) do { \
1f3433
     if ((x)->options.options_len > 0) { \
1f3433
         gp_debug_printf("[ "); \
1f3433
-        for (int i = 0; i < (x)->options.options_len; i++) { \
1f3433
+        for (unsigned i = 0; i < (x)->options.options_len; i++) { \
1f3433
             gpdbg_gssx_option(&(x)->options.options_val[i]); \
1f3433
         } \
1f3433
         gp_debug_printf("] "); \
1f3433
@@ -168,7 +168,7 @@ void gpdbg_gssx_call_ctx(gssx_call_ctx *x)
1f3433
 #define gpdbg_name_attributes(X) do { \
1f3433
     gp_debug_printf("[ "); \
1f3433
     if (x->name_attributes.name_attributes_len > 0) { \
1f3433
-        for (int i = 0; i < x->name_attributes.name_attributes_len; i++) { \
1f3433
+        for (unsigned i = 0; i < x->name_attributes.name_attributes_len; i++) { \
1f3433
             gpdbg_gssx_name_attr( \
1f3433
                 &x->name_attributes.name_attributes_val[i]); \
1f3433
         } \
1f3433
@@ -209,7 +209,7 @@ void gpdbg_gssx_cred(gssx_cred *x)
1f3433
     gp_debug_printf("{ ");
1f3433
     gpdbg_gssx_name(&x->desired_name);
1f3433
     gp_debug_printf("[ ");
1f3433
-    for (int i = 0; i < x->elements.elements_len; i++) {
1f3433
+    for (unsigned i = 0; i < x->elements.elements_len; i++) {
1f3433
         gpdbg_gssx_cred_element(&x->elements.elements_val[i]);
1f3433
     }
1f3433
     gp_debug_printf("] ");
1f3433
@@ -289,17 +289,17 @@ void gpdbg_gssx_res_indicate_mechs(gssx_res_indicate_mechs *x)
1f3433
     gp_debug_printf("    GSSX_RES_INDICATE_MECHS( status: ");
1f3433
     gpdbg_gssx_status(&x->status);
1f3433
     gp_debug_printf("mechs: [ ");
1f3433
-    for (int i = 0; i < x->mechs.mechs_len; i++) {
1f3433
+    for (unsigned i = 0; i < x->mechs.mechs_len; i++) {
1f3433
         gpdbg_gssx_mech_info(&x->mechs.mechs_val[i]);
1f3433
     }
1f3433
     gp_debug_printf("] ");
1f3433
     gp_debug_printf("mech_attr_descs: [ ");
1f3433
-    for (int i = 0; i < x->mech_attr_descs.mech_attr_descs_len; i++) {
1f3433
+    for (unsigned i = 0; i < x->mech_attr_descs.mech_attr_descs_len; i++) {
1f3433
         gpdbg_gssx_mech_attr(&x->mech_attr_descs.mech_attr_descs_val[i]);
1f3433
     }
1f3433
     gp_debug_printf("] ");
1f3433
     gp_debug_printf("supported_extensions: [ ");
1f3433
-    for (int i = 0;
1f3433
+    for (unsigned i = 0;
1f3433
          i < x->supported_extensions.supported_extensions_len; i++) {
1f3433
         gpdbg_gssx_buffer(
1f3433
             &x->supported_extensions.supported_extensions_val[i]);
1f3433
@@ -602,7 +602,7 @@ void gpdbg_gssx_arg_wrap(gssx_arg_wrap *x)
1f3433
     gp_debug_printf("conf_req: ");
1f3433
     gp_debug_printf("%d ", (int)x->conf_req);
1f3433
     gp_debug_printf("message_buffer: [ ");
1f3433
-    for (int i = 0; i < x->message_buffer.message_buffer_len; i++) {
1f3433
+    for (unsigned i = 0; i < x->message_buffer.message_buffer_len; i++) {
1f3433
         gpdbg_octet_string(&x->message_buffer.message_buffer_val[i]);
1f3433
     }
1f3433
     gp_debug_printf("] ");
1f3433
@@ -618,7 +618,7 @@ void gpdbg_gssx_res_wrap(gssx_res_wrap *x)
1f3433
     gp_debug_printf("context_handle: ");
1f3433
     GPRPCDEBUG(gssx_ctx, x->context_handle);
1f3433
     gp_debug_printf("token_buffer: [ ");
1f3433
-    for (int i = 0; i < x->token_buffer.token_buffer_len; i++) {
1f3433
+    for (unsigned i = 0; i < x->token_buffer.token_buffer_len; i++) {
1f3433
         gpdbg_octet_string(&x->token_buffer.token_buffer_val[i]);
1f3433
     }
1f3433
     gp_debug_printf("] ");
1f3433
@@ -640,7 +640,7 @@ void gpdbg_gssx_arg_unwrap(gssx_arg_unwrap *x)
1f3433
     gp_debug_printf("context_handle: ");
1f3433
     gpdbg_gssx_ctx(&x->context_handle);
1f3433
     gp_debug_printf("token_buffer: [ ");
1f3433
-    for (int i = 0; i < x->token_buffer.token_buffer_len; i++) {
1f3433
+    for (unsigned i = 0; i < x->token_buffer.token_buffer_len; i++) {
1f3433
         gpdbg_octet_string(&x->token_buffer.token_buffer_val[i]);
1f3433
     }
1f3433
     gp_debug_printf("] ");
1f3433
@@ -656,7 +656,7 @@ void gpdbg_gssx_res_unwrap(gssx_res_unwrap *x)
1f3433
     gp_debug_printf("context_handle: ");
1f3433
     GPRPCDEBUG(gssx_ctx, x->context_handle);
1f3433
     gp_debug_printf("message_buffer: [ ");
1f3433
-    for (int i = 0; i < x->message_buffer.message_buffer_len; i++) {
1f3433
+    for (unsigned i = 0; i < x->message_buffer.message_buffer_len; i++) {
1f3433
         gpdbg_octet_string(&x->message_buffer.message_buffer_val[i]);
1f3433
     }
1f3433
     gp_debug_printf("] ");
1f3433
diff --git a/proxy/src/gp_rpc_indicate_mechs.c b/proxy/src/gp_rpc_indicate_mechs.c
1f3433
index 8abbc7f..6ae6756 100644
1f3433
--- a/proxy/src/gp_rpc_indicate_mechs.c
1f3433
+++ b/proxy/src/gp_rpc_indicate_mechs.c
1f3433
@@ -25,8 +25,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
1f3433
     uint32_t ret_maj;
1f3433
     uint32_t ret_min;
1f3433
     int present;
1f3433
-    int h, i, j;
1f3433
-    int ret;
1f3433
+     int ret;
1f3433
 
1f3433
     ima = &arg->indicate_mechs;
1f3433
     imr = &res->indicate_mechs;
1f3433
@@ -53,8 +52,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
1f3433
     }
1f3433
     imr->mechs.mechs_len = mech_set->count;
1f3433
 
1f3433
-    for (i = 0, h = 0; i < mech_set->count; i++, h++) {
1f3433
-
1f3433
+    for (unsigned i = 0, h = 0; i < mech_set->count; i++, h++) {
1f3433
         mi = &imr->mechs.mechs_val[h];
1f3433
 
1f3433
         ret = gp_conv_oid_to_gssx(&mech_set->elements[i], &mi->mech);
1f3433
@@ -104,8 +102,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
1f3433
             ret_min = ret;
1f3433
             goto done;
1f3433
         }
1f3433
-        for (j = 0; j < mech_attrs->count; j++) {
1f3433
-
1f3433
+        for (unsigned j = 0; j < mech_attrs->count; j++) {
1f3433
             ret_maj = gss_test_oid_set_member(&ret_min,
1f3433
                                               &mech_attrs->elements[j],
1f3433
                                               attr_set,
1f3433
@@ -136,8 +133,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
1f3433
             goto done;
1f3433
         }
1f3433
 
1f3433
-        for (j = 0; j < known_mech_attrs->count; j++) {
1f3433
-
1f3433
+        for (unsigned j = 0; j < known_mech_attrs->count; j++) {
1f3433
             ret_maj = gss_test_oid_set_member(&ret_min,
1f3433
                                               &known_mech_attrs->elements[j],
1f3433
                                               attr_set,
1f3433
@@ -205,8 +201,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
1f3433
     }
1f3433
     imr->mech_attr_descs.mech_attr_descs_len = attr_set->count;
1f3433
 
1f3433
-    for (i = 0; i < attr_set->count; i++) {
1f3433
-
1f3433
+    for (unsigned i = 0; i < attr_set->count; i++) {
1f3433
         ma = &imr->mech_attr_descs.mech_attr_descs_val[i];
1f3433
 
1f3433
         ret = gp_conv_oid_to_gssx(&attr_set->elements[i], &ma->attr);
1f3433
diff --git a/proxy/src/gp_socket.c b/proxy/src/gp_socket.c
1f3433
index 829ff21..17ecf7c 100644
1f3433
--- a/proxy/src/gp_socket.c
1f3433
+++ b/proxy/src/gp_socket.c
1f3433
@@ -303,7 +303,7 @@ static void gp_socket_read(verto_ctx *vctx, verto_ev *ev)
1f3433
     struct gp_buffer *rbuf;
1f3433
     uint32_t size;
1f3433
     bool header = false;
1f3433
-    size_t rn;
1f3433
+    ssize_t rn;
1f3433
     int ret;
1f3433
     int fd;
1f3433
 
1f3433
@@ -487,7 +487,7 @@ static void gp_socket_write(verto_ctx *vctx, verto_ev *ev)
1f3433
         return;
1f3433
     }
1f3433
     if (vecs == 2) {
1f3433
-        if (wn < sizeof(size)) {
1f3433
+        if (wn < (ssize_t) sizeof(size)) {
1f3433
             /* don't bother trying to handle sockets that can't
1f3433
              * buffer even 4 bytes */
1f3433
             gp_conn_free(wbuf->conn);
1f3433
diff --git a/proxy/src/gp_util.c b/proxy/src/gp_util.c
1f3433
index ca83eb3..f158b84 100644
1f3433
--- a/proxy/src/gp_util.c
1f3433
+++ b/proxy/src/gp_util.c
1f3433
@@ -109,7 +109,7 @@ char *gp_strerror(int errnum)
1f3433
 ssize_t gp_safe_read(int fd, void *buf, size_t count)
1f3433
 {
1f3433
     char *b = (char *)buf;
1f3433
-    ssize_t len = 0;
1f3433
+    size_t len = 0;
1f3433
     ssize_t ret;
1f3433
 
1f3433
     do {
1f3433
@@ -128,7 +128,7 @@ ssize_t gp_safe_read(int fd, void *buf, size_t count)
1f3433
 ssize_t gp_safe_write(int fd, const void *buf, size_t count)
1f3433
 {
1f3433
     const char *b = (const char *)buf;
1f3433
-    ssize_t len = 0;
1f3433
+    size_t len = 0;
1f3433
     ssize_t ret;
1f3433
 
1f3433
     do {
1f3433
diff --git a/proxy/tests/t_utils.c b/proxy/tests/t_utils.c
1f3433
index 6af9a16..36f7bd1 100644
1f3433
--- a/proxy/tests/t_utils.c
1f3433
+++ b/proxy/tests/t_utils.c
1f3433
@@ -8,7 +8,7 @@
1f3433
 int t_send_buffer(int fd, char *buf, uint32_t len)
1f3433
 {
1f3433
     uint32_t size;
1f3433
-    size_t wn;
1f3433
+    ssize_t wn;
1f3433
     size_t pos;
1f3433
 
1f3433
     size = htonl(len);
1f3433
@@ -36,7 +36,7 @@ int t_send_buffer(int fd, char *buf, uint32_t len)
1f3433
 int t_recv_buffer(int fd, char *buf, uint32_t *len)
1f3433
 {
1f3433
     uint32_t size;
1f3433
-    size_t rn;
1f3433
+    ssize_t rn;
1f3433
     size_t pos;
1f3433
 
1f3433
     rn = read(fd, &size, sizeof(uint32_t));