Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-distro / recipes-security / gssproxy / files / Fix-mismatched-sign-comparisons.patch
1 From a68b8b418bfc42c628fee605cc52dca92ab410c9 Mon Sep 17 00:00:00 2001
2 From: Robbie Harwood <rharwood@redhat.com>
3 Date: Wed, 15 Mar 2017 14:52:08 -0400
4 Subject: [PATCH] Fix mismatched sign comparisons
5
6 We are c99, so also migrate to `for`-loop initializers where possible for
7 clarity.
8
9 Signed-off-by: Robbie Harwood <rharwood@redhat.com>
10 Reviewed-by: Simo Sorce <simo@redhat.com>
11 Merges: #173
12 (cherry picked from commit 377e92c7ead312c530b233a1e023493ecde033d6)
13 ---
14  proxy/src/client/gpm_acquire_cred.c          | 11 ++-----
15  proxy/src/client/gpm_common.c                |  4 +--
16  proxy/src/client/gpm_import_and_canon_name.c |  7 ++---
17  proxy/src/client/gpm_indicate_mechs.c        | 33 +++++++++-----------
18  proxy/src/gp_common.h                        |  3 +-
19  proxy/src/gp_config.c                        |  9 ++----
20  proxy/src/gp_conv.c                          |  6 ++--
21  proxy/src/gp_creds.c                         |  3 +-
22  proxy/src/gp_export.c                        |  9 ++----
23  proxy/src/gp_rpc_acquire_cred.c              |  5 ++-
24  proxy/src/gp_rpc_debug.c                     | 26 +++++++--------
25  proxy/src/gp_rpc_indicate_mechs.c            | 15 +++------
26  proxy/src/gp_socket.c                        |  4 +--
27  proxy/src/gp_util.c                          |  4 +--
28  proxy/tests/t_utils.c                        |  4 +--
29  15 files changed, 58 insertions(+), 85 deletions(-)
30
31 diff --git a/proxy/src/client/gpm_acquire_cred.c b/proxy/src/client/gpm_acquire_cred.c
32 index 632973d..8e30e1d 100644
33 --- a/proxy/src/client/gpm_acquire_cred.c
34 +++ b/proxy/src/client/gpm_acquire_cred.c
35 @@ -6,8 +6,6 @@ static int gpmint_cred_to_actual_mechs(gssx_cred *c, gss_OID_set *a)
36  {
37      gssx_cred_element *e;
38      gss_OID_set m = GSS_C_NO_OID_SET;
39 -    int i;
40 -
41  
42      if (c->elements.elements_len) {
43  
44 @@ -22,7 +20,7 @@ static int gpmint_cred_to_actual_mechs(gssx_cred *c, gss_OID_set *a)
45              return ENOMEM;
46          }
47  
48 -        for (i = 0; i < c->elements.elements_len; i++) {
49 +        for (unsigned i = 0; i < c->elements.elements_len; i++) {
50              e = &c->elements.elements_val[i];
51  
52              m->elements[i].elements = gp_memdup(e->mech.octet_string_val,
53 @@ -280,7 +278,6 @@ OM_uint32 gpm_inquire_cred(OM_uint32 *minor_status,
54      uint32_t ret_maj = GSS_S_COMPLETE;
55      uint32_t life;
56      int cu;
57 -    int i;
58  
59      if (!cred) {
60          *minor_status = 0;
61 @@ -308,8 +305,7 @@ OM_uint32 gpm_inquire_cred(OM_uint32 *minor_status,
62      life = GSS_C_INDEFINITE;
63      cu = -1;
64  
65 -    for (i = 0; i < cred->elements.elements_len; i++) {
66 -
67 +    for (unsigned i = 0; i < cred->elements.elements_len; i++) {
68          e = &cred->elements.elements_val[i];
69  
70          switch (e->cred_usage) {
71 @@ -402,7 +398,7 @@ OM_uint32 gpm_inquire_cred_by_mech(OM_uint32 *minor_status,
72      gss_OID_desc tmp_oid;
73      uint32_t ret_min = 0;
74      uint32_t ret_maj = GSS_S_COMPLETE;
75 -    int i;
76 +    unsigned i;
77  
78      if (!cred) {
79          *minor_status = 0;
80 @@ -414,7 +410,6 @@ OM_uint32 gpm_inquire_cred_by_mech(OM_uint32 *minor_status,
81      }
82  
83      for (i = 0; i < cred->elements.elements_len; i++) {
84 -
85          e = &cred->elements.elements_val[i];
86          gp_conv_gssx_to_oid(&e->mech, &tmp_oid);
87          if (!gss_oid_equal(&tmp_oid, mech_type)) {
88 diff --git a/proxy/src/client/gpm_common.c b/proxy/src/client/gpm_common.c
89 index 030765a..8c96986 100644
90 --- a/proxy/src/client/gpm_common.c
91 +++ b/proxy/src/client/gpm_common.c
92 @@ -166,7 +166,7 @@ static int gpm_send_buffer(struct gpm_ctx *gpmctx,
93                             char *buffer, uint32_t length)
94  {
95      uint32_t size;
96 -    size_t wn;
97 +    ssize_t wn;
98      size_t pos;
99      bool retry;
100      int ret;
101 @@ -232,7 +232,7 @@ static int gpm_recv_buffer(struct gpm_ctx *gpmctx,
102                             char *buffer, uint32_t *length)
103  {
104      uint32_t size;
105 -    size_t rn;
106 +    ssize_t rn;
107      size_t pos;
108      int ret;
109  
110 diff --git a/proxy/src/client/gpm_import_and_canon_name.c b/proxy/src/client/gpm_import_and_canon_name.c
111 index 83d0736..70149a3 100644
112 --- a/proxy/src/client/gpm_import_and_canon_name.c
113 +++ b/proxy/src/client/gpm_import_and_canon_name.c
114 @@ -275,7 +275,6 @@ OM_uint32 gpm_inquire_name(OM_uint32 *minor_status,
115  {
116      gss_buffer_set_t xattrs = GSS_C_NO_BUFFER_SET;
117      int ret;
118 -    int i;
119  
120      *minor_status = 0;
121  
122 @@ -306,13 +305,13 @@ OM_uint32 gpm_inquire_name(OM_uint32 *minor_status,
123              *minor_status = ENOMEM;
124              return GSS_S_FAILURE;
125          }
126 -        for (i = 0; i < xattrs->count; i++) {
127 +        for (unsigned i = 0; i < xattrs->count; i++) {
128              ret = gp_copy_gssx_to_buffer(
129                          &name->name_attributes.name_attributes_val[i].attr,
130                          &xattrs->elements[i]);
131              if (ret) {
132 -                for (--i; i >= 0; i--) {
133 -                    free(xattrs->elements[i].value);
134 +                for (; i > 0; i--) {
135 +                    free(xattrs->elements[i-1].value);
136                  }
137                  free(xattrs->elements);
138                  free(xattrs);
139 diff --git a/proxy/src/client/gpm_indicate_mechs.c b/proxy/src/client/gpm_indicate_mechs.c
140 index d4df923..b019a96 100644
141 --- a/proxy/src/client/gpm_indicate_mechs.c
142 +++ b/proxy/src/client/gpm_indicate_mechs.c
143 @@ -51,7 +51,6 @@ static uint32_t gpm_copy_gss_OID_set(uint32_t *minor_status,
144      gss_OID_set n;
145      uint32_t ret_maj;
146      uint32_t ret_min;
147 -    int i;
148  
149      ret_maj = gss_create_empty_oid_set(&ret_min, &n);
150      if (ret_maj) {
151 @@ -59,7 +58,7 @@ static uint32_t gpm_copy_gss_OID_set(uint32_t *minor_status,
152          return ret_maj;
153      }
154  
155 -    for (i = 0; i < oldset->count; i++) {
156 +    for (size_t i = 0; i < oldset->count; i++) {
157          ret_maj = gss_add_oid_set_member(&ret_min, &oldset->elements[i], &n);
158          if (ret_maj) {
159              *minor_status = ret_min;
160 @@ -124,7 +123,6 @@ static void gpmint_indicate_mechs(void)
161      uint32_t ret_min;
162      uint32_t ret_maj = 0;
163      int ret = 0;
164 -    int i;
165  
166      memset(arg, 0, sizeof(gssx_arg_indicate_mechs));
167      memset(res, 0, sizeof(gssx_res_indicate_mechs));
168 @@ -158,7 +156,7 @@ static void gpmint_indicate_mechs(void)
169          goto done;
170      }
171  
172 -    for (i = 0; i < res->mechs.mechs_len; i++) {
173 +    for (unsigned i = 0; i < res->mechs.mechs_len; i++) {
174          mi = &res->mechs.mechs_val[i];
175          gi = &global_mechs.info[i];
176  
177 @@ -222,7 +220,7 @@ static void gpmint_indicate_mechs(void)
178          goto done;
179      }
180  
181 -    for (i = 0; i < res->mech_attr_descs.mech_attr_descs_len; i++) {
182 +    for (unsigned i = 0; i < res->mech_attr_descs.mech_attr_descs_len; i++) {
183          ma = &res->mech_attr_descs.mech_attr_descs_val[i];
184          ga = &global_mechs.desc[i];
185  
186 @@ -249,7 +247,7 @@ static void gpmint_indicate_mechs(void)
187  
188  done:
189      if (ret || ret_maj) {
190 -        for (i = 0; i < global_mechs.desc_len; i++) {
191 +        for (unsigned i = 0; i < global_mechs.desc_len; i++) {
192              ga = &global_mechs.desc[i];
193              gss_release_oid(&discard, &ga->attr);
194              gss_release_buffer(&discard, ga->name);
195 @@ -258,7 +256,7 @@ done:
196          }
197          free(global_mechs.desc);
198          global_mechs.desc = NULL;
199 -        for (i = 0; i < global_mechs.info_len; i++) {
200 +        for (unsigned i = 0; i < global_mechs.info_len; i++) {
201              gi = &global_mechs.info[i];
202              gss_release_oid(&discard, &gi->mech);
203              gss_release_oid_set(&discard, &gi->name_types);
204 @@ -335,7 +333,6 @@ OM_uint32 gpm_inquire_names_for_mech(OM_uint32 *minor_status,
205  {
206      uint32_t ret_min;
207      uint32_t ret_maj;
208 -    int i;
209  
210      if (!minor_status) {
211          return GSS_S_CALL_INACCESSIBLE_WRITE;
212 @@ -351,7 +348,7 @@ OM_uint32 gpm_inquire_names_for_mech(OM_uint32 *minor_status,
213          return GSS_S_FAILURE;
214      }
215  
216 -    for (i = 0; i < global_mechs.info_len; i++) {
217 +    for (unsigned i = 0; i < global_mechs.info_len; i++) {
218          if (!gpm_equal_oids(global_mechs.info[i].mech, mech_type)) {
219              continue;
220          }
221 @@ -375,7 +372,6 @@ OM_uint32 gpm_inquire_mechs_for_name(OM_uint32 *minor_status,
222      uint32_t discard;
223      gss_OID name_type = GSS_C_NO_OID;
224      int present;
225 -    int i;
226  
227      if (!minor_status) {
228          return GSS_S_CALL_INACCESSIBLE_WRITE;
229 @@ -402,7 +398,7 @@ OM_uint32 gpm_inquire_mechs_for_name(OM_uint32 *minor_status,
230          goto done;
231      }
232  
233 -    for (i = 0; i < global_mechs.info_len; i++) {
234 +    for (unsigned i = 0; i < global_mechs.info_len; i++) {
235          ret_maj = gss_test_oid_set_member(&ret_min, name_type,
236                                            global_mechs.info[i].name_types,
237                                            &present);
238 @@ -439,7 +435,6 @@ OM_uint32 gpm_inquire_attrs_for_mech(OM_uint32 *minor_status,
239      uint32_t ret_min;
240      uint32_t ret_maj;
241      uint32_t discard;
242 -    int i;
243  
244      if (!minor_status) {
245          return GSS_S_CALL_INACCESSIBLE_WRITE;
246 @@ -451,7 +446,7 @@ OM_uint32 gpm_inquire_attrs_for_mech(OM_uint32 *minor_status,
247          return GSS_S_FAILURE;
248      }
249  
250 -    for (i = 0; i < global_mechs.info_len; i++) {
251 +    for (unsigned i = 0; i < global_mechs.info_len; i++) {
252          if (!gpm_equal_oids(global_mechs.info[i].mech, mech)) {
253              continue;
254          }
255 @@ -495,7 +490,6 @@ OM_uint32 gpm_inquire_saslname_for_mech(OM_uint32 *minor_status,
256      uint32_t ret_min;
257      uint32_t ret_maj;
258      uint32_t discard;
259 -    int i;
260  
261      if (!minor_status) {
262          return GSS_S_CALL_INACCESSIBLE_WRITE;
263 @@ -511,7 +505,7 @@ OM_uint32 gpm_inquire_saslname_for_mech(OM_uint32 *minor_status,
264          return GSS_S_FAILURE;
265      }
266  
267 -    for (i = 0; i < global_mechs.info_len; i++) {
268 +    for (unsigned i = 0; i < global_mechs.info_len; i++) {
269          if (!gpm_equal_oids(global_mechs.info[i].mech, desired_mech)) {
270              continue;
271          }
272 @@ -554,7 +548,6 @@ OM_uint32 gpm_display_mech_attr(OM_uint32 *minor_status,
273      uint32_t ret_min;
274      uint32_t ret_maj;
275      uint32_t discard;
276 -    int i;
277  
278      if (!minor_status) {
279          return GSS_S_CALL_INACCESSIBLE_WRITE;
280 @@ -570,7 +563,7 @@ OM_uint32 gpm_display_mech_attr(OM_uint32 *minor_status,
281          return GSS_S_FAILURE;
282      }
283  
284 -    for (i = 0; i < global_mechs.desc_len; i++) {
285 +    for (unsigned i = 0; i < global_mechs.desc_len; i++) {
286          if (!gpm_equal_oids(global_mechs.desc[i].attr, mech_attr)) {
287              continue;
288          }
289 @@ -614,7 +607,6 @@ OM_uint32 gpm_indicate_mechs_by_attrs(OM_uint32 *minor_status,
290      uint32_t ret_maj;
291      uint32_t discard;
292      int present;
293 -    int i, j;
294  
295      if (!minor_status) {
296          return GSS_S_CALL_INACCESSIBLE_WRITE;
297 @@ -636,8 +628,9 @@ OM_uint32 gpm_indicate_mechs_by_attrs(OM_uint32 *minor_status,
298          return ret_maj;
299      }
300  
301 -    for (i = 0; i < global_mechs.info_len; i++) {
302 +    for (unsigned i = 0; i < global_mechs.info_len; i++) {
303          if (desired_mech_attrs != GSS_C_NO_OID_SET) {
304 +            unsigned j;
305              for (j = 0; j < desired_mech_attrs->count; j++) {
306                  ret_maj = gss_test_oid_set_member(&ret_min,
307                                              &desired_mech_attrs->elements[j],
308 @@ -657,6 +650,7 @@ OM_uint32 gpm_indicate_mechs_by_attrs(OM_uint32 *minor_status,
309              }
310          }
311          if (except_mech_attrs != GSS_C_NO_OID_SET) {
312 +            unsigned j;
313              for (j = 0; j < except_mech_attrs->count; j++) {
314                  ret_maj = gss_test_oid_set_member(&ret_min,
315                                              &except_mech_attrs->elements[j],
316 @@ -676,6 +670,7 @@ OM_uint32 gpm_indicate_mechs_by_attrs(OM_uint32 *minor_status,
317              }
318          }
319          if (critical_mech_attrs != GSS_C_NO_OID_SET) {
320 +            unsigned j;
321              for (j = 0; j < critical_mech_attrs->count; j++) {
322                  ret_maj = gss_test_oid_set_member(&ret_min,
323                                      &critical_mech_attrs->elements[j],
324 diff --git a/proxy/src/gp_common.h b/proxy/src/gp_common.h
325 index edc23b4..4f76e58 100644
326 --- a/proxy/src/gp_common.h
327 +++ b/proxy/src/gp_common.h
328 @@ -104,9 +104,8 @@ union gp_rpc_res {
329  #define gp_options_find(res, opts, name, len) \
330  do { \
331      struct gssx_option *_v; \
332 -    int _o; \
333      res = NULL; \
334 -    for (_o = 0; _o < opts.options_len; _o++) { \
335 +    for (unsigned _o = 0; _o < opts.options_len; _o++) { \
336          _v = &opts.options_val[_o]; \
337          if (gp_option_name_match(_v, name, len)) { \
338              res = _v; \
339 diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c
340 index 5c1ca02..a671333 100644
341 --- a/proxy/src/gp_config.c
342 +++ b/proxy/src/gp_config.c
343 @@ -57,11 +57,9 @@ static void free_str_array(const char ***a, int *count)
344  
345  void free_cred_store_elements(gss_key_value_set_desc *cs)
346  {
347 -    int i;
348 -
349      if (!cs->elements) return;
350  
351 -    for (i = 0; i < cs->count; i++) {
352 +    for (unsigned i = 0; i < cs->count; i++) {
353          safefree(cs->elements[i].key);
354          safefree(cs->elements[i].value);
355      }
356 @@ -146,7 +144,7 @@ static int get_krb5_mech_cfg(struct gp_service *svc,
357                                       &count, &strings);
358      if (ret == 0) {
359          const char *p;
360 -        size_t len;
361 +        ssize_t len;
362          char *key;
363  
364          svc->krb5.store.elements =
365 @@ -698,7 +696,6 @@ struct gp_creds_handle *gp_service_get_creds_handle(struct gp_service *svc)
366  void free_config(struct gp_config **cfg)
367  {
368      struct gp_config *config = *cfg;
369 -    uint32_t i;
370  
371      if (!config) {
372          return;
373 @@ -709,7 +706,7 @@ void free_config(struct gp_config **cfg)
374      free(config->socket_name);
375      free(config->proxy_user);
376  
377 -    for (i=0; i < config->num_svcs; i++) {
378 +    for (int i = 0; i < config->num_svcs; i++) {
379          gp_service_free(config->svcs[i]);
380          safefree(config->svcs[i]);
381      }
382 diff --git a/proxy/src/gp_conv.c b/proxy/src/gp_conv.c
383 index 71d6d9d..b874b06 100644
384 --- a/proxy/src/gp_conv.c
385 +++ b/proxy/src/gp_conv.c
386 @@ -599,7 +599,6 @@ done:
387  int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out)
388  {
389      gss_OID_set o;
390 -    int i;
391  
392      if (in->gssx_OID_set_len == 0) {
393          *out = GSS_C_NO_OID_SET;
394 @@ -618,7 +617,7 @@ int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out)
395          return ENOMEM;
396      }
397  
398 -    for (i = 0; i < o->count; i++) {
399 +    for (size_t i = 0; i < o->count; i++) {
400          o->elements[i].elements =
401                          gp_memdup(in->gssx_OID_set_val[i].octet_string_val,
402                                    in->gssx_OID_set_val[i].octet_string_len);
403 @@ -641,7 +640,6 @@ int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out)
404  int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out)
405  {
406      int ret;
407 -    int i;
408  
409      if (in->count == 0) {
410          return 0;
411 @@ -653,7 +651,7 @@ int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out)
412          return ENOMEM;
413      }
414  
415 -    for (i = 0; i < in->count; i++) {
416 +    for (size_t i = 0; i < in->count; i++) {
417          ret = gp_conv_octet_string(in->elements[i].length,
418                                     in->elements[i].elements,
419                                     &out->gssx_OID_set_val[i]);
420 diff --git a/proxy/src/gp_creds.c b/proxy/src/gp_creds.c
421 index 6570b06..e05ad01 100644
422 --- a/proxy/src/gp_creds.c
423 +++ b/proxy/src/gp_creds.c
424 @@ -312,7 +312,6 @@ static int gp_get_cred_environment(struct gp_call_ctx *gpcall,
425      int k_num = -1;
426      int ck_num = -1;
427      int cc_num = -1;
428 -    int d;
429  
430      memset(cs, 0, sizeof(gss_key_value_set_desc));
431  
432 @@ -419,7 +418,7 @@ static int gp_get_cred_environment(struct gp_call_ctx *gpcall,
433          ret = ENOMEM;
434          goto done;
435      }
436 -    for (d = 0; d < svc->krb5.store.count; d++) {
437 +    for (unsigned d = 0; d < svc->krb5.store.count; d++) {
438          if (strcmp(svc->krb5.store.elements[d].key, "client_keytab") == 0) {
439              ck_num = cs->count;
440          } else if (strcmp(svc->krb5.store.elements[d].key, "keytab") == 0) {
441 diff --git a/proxy/src/gp_export.c b/proxy/src/gp_export.c
442 index 12b8d5f..3a927c9 100644
443 --- a/proxy/src/gp_export.c
444 +++ b/proxy/src/gp_export.c
445 @@ -288,7 +288,6 @@ uint32_t gp_export_gssx_cred(uint32_t *min, struct gp_call_ctx *gpcall,
446      uint32_t acceptor_lifetime = 0;
447      struct gssx_cred_element *el;
448      int ret;
449 -    int i, j;
450      struct gp_creds_handle *handle = NULL;
451      gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
452  
453 @@ -314,8 +313,7 @@ uint32_t gp_export_gssx_cred(uint32_t *min, struct gp_call_ctx *gpcall,
454      }
455      out->elements.elements_len = mechanisms->count;
456  
457 -    for (i = 0, j = 0; i < mechanisms->count; i++, j++) {
458 -
459 +    for (unsigned i = 0, j = 0; i < mechanisms->count; i++, j++) {
460          el = &out->elements.elements_val[j];
461  
462          ret_maj = gss_inquire_cred_by_mech(&ret_min, *in,
463 @@ -399,11 +397,10 @@ static void gp_set_cred_options(gssx_cred *cred, gss_cred_id_t gss_cred)
464      krb5_enctype *ktypes;
465      bool no_ci_flags = false;
466      uint32_t maj, min;
467 -    int i, j;
468  
469 -    for (i = 0; i < cred->elements.elements_len; i++) {
470 +    for (unsigned i = 0; i < cred->elements.elements_len; i++) {
471          ce = &cred->elements.elements_val[i];
472 -        for (j = 0; j < ce->options.options_len; j++) {
473 +        for (unsigned j = 0; j < ce->options.options_len; j++) {
474              op = &ce->options.options_val[j];
475              if ((op->option.octet_string_len ==
476                      sizeof(KRB5_SET_ALLOWED_ENCTYPE)) &&
477 diff --git a/proxy/src/gp_rpc_acquire_cred.c b/proxy/src/gp_rpc_acquire_cred.c
478 index e9c7d56..fcb4fbe 100644
479 --- a/proxy/src/gp_rpc_acquire_cred.c
480 +++ b/proxy/src/gp_rpc_acquire_cred.c
481 @@ -20,7 +20,6 @@ int gp_acquire_cred(struct gp_call_ctx *gpcall,
482      gss_cred_id_t *add_out_cred = NULL;
483      int acquire_type = ACQ_NORMAL;
484      int ret;
485 -    int i;
486  
487      aca = &arg->acquire_cred;
488      acr = &res->acquire_cred;
489 @@ -63,7 +62,7 @@ int gp_acquire_cred(struct gp_call_ctx *gpcall,
490              goto done;
491          }
492  
493 -        for (i = 0; i < desired_mechs->count; i++) {
494 +        for (unsigned i = 0; i < desired_mechs->count; i++) {
495              desired_mech = &desired_mechs->elements[i];
496  
497              if (!gp_creds_allowed_mech(gpcall, desired_mech)) {
498 @@ -93,7 +92,7 @@ int gp_acquire_cred(struct gp_call_ctx *gpcall,
499  
500      cred_usage = gp_conv_gssx_to_cred_usage(aca->cred_usage);
501  
502 -    for (i = 0; i < use_mechs->count; i++) {
503 +    for (unsigned i = 0; i < use_mechs->count; i++) {
504          desired_mech = &use_mechs->elements[i];
505          /* this should really be folded into an extended
506           * gss_add_cred in gssapi that can accept a set of URIs
507 diff --git a/proxy/src/gp_rpc_debug.c b/proxy/src/gp_rpc_debug.c
508 index 2e2c050..a814448 100644
509 --- a/proxy/src/gp_rpc_debug.c
510 +++ b/proxy/src/gp_rpc_debug.c
511 @@ -19,7 +19,7 @@ void gpdbg_octet_string(octet_string *x)
512          }
513          fprintf(stderr, "... ] ");
514      } else {
515 -        for (int i = 0; i < x->octet_string_len; i++) {
516 +        for (unsigned i = 0; i < x->octet_string_len; i++) {
517              fprintf(stderr, "%x", x->octet_string_val[i]);
518          }
519          fprintf(stderr, " ] ");
520 @@ -55,7 +55,7 @@ void gpdbg_gssx_OID(gssx_OID *x)
521  void gpdbg_gssx_OID_set(gssx_OID_set *x)
522  {
523      gp_debug_printf("{ ");
524 -    for (int i = 0; i < x->gssx_OID_set_len; i++) {
525 +    for (unsigned i = 0; i < x->gssx_OID_set_len; i++) {
526          gpdbg_gssx_OID(&x->gssx_OID_set_val[i]);
527      }
528      gp_debug_printf("} ");
529 @@ -90,7 +90,7 @@ void gpdbg_gssx_option(gssx_option *x)
530  #define gpdbg_extensions(x) do { \
531      if ((x)->extensions.extensions_len > 0) { \
532          gp_debug_printf("[ "); \
533 -        for (int i = 0; i < (x)->extensions.extensions_len; i++) { \
534 +        for (unsigned i = 0; i < (x)->extensions.extensions_len; i++) { \
535              gpdbg_gssx_option(&(x)->extensions.extensions_val[i]); \
536          } \
537          gp_debug_printf("] "); \
538 @@ -100,7 +100,7 @@ void gpdbg_gssx_option(gssx_option *x)
539  #define gpdbg_options(x) do { \
540      if ((x)->options.options_len > 0) { \
541          gp_debug_printf("[ "); \
542 -        for (int i = 0; i < (x)->options.options_len; i++) { \
543 +        for (unsigned i = 0; i < (x)->options.options_len; i++) { \
544              gpdbg_gssx_option(&(x)->options.options_val[i]); \
545          } \
546          gp_debug_printf("] "); \
547 @@ -168,7 +168,7 @@ void gpdbg_gssx_call_ctx(gssx_call_ctx *x)
548  #define gpdbg_name_attributes(X) do { \
549      gp_debug_printf("[ "); \
550      if (x->name_attributes.name_attributes_len > 0) { \
551 -        for (int i = 0; i < x->name_attributes.name_attributes_len; i++) { \
552 +        for (unsigned i = 0; i < x->name_attributes.name_attributes_len; i++) { \
553              gpdbg_gssx_name_attr( \
554                  &x->name_attributes.name_attributes_val[i]); \
555          } \
556 @@ -209,7 +209,7 @@ void gpdbg_gssx_cred(gssx_cred *x)
557      gp_debug_printf("{ ");
558      gpdbg_gssx_name(&x->desired_name);
559      gp_debug_printf("[ ");
560 -    for (int i = 0; i < x->elements.elements_len; i++) {
561 +    for (unsigned i = 0; i < x->elements.elements_len; i++) {
562          gpdbg_gssx_cred_element(&x->elements.elements_val[i]);
563      }
564      gp_debug_printf("] ");
565 @@ -289,17 +289,17 @@ void gpdbg_gssx_res_indicate_mechs(gssx_res_indicate_mechs *x)
566      gp_debug_printf("    GSSX_RES_INDICATE_MECHS( status: ");
567      gpdbg_gssx_status(&x->status);
568      gp_debug_printf("mechs: [ ");
569 -    for (int i = 0; i < x->mechs.mechs_len; i++) {
570 +    for (unsigned i = 0; i < x->mechs.mechs_len; i++) {
571          gpdbg_gssx_mech_info(&x->mechs.mechs_val[i]);
572      }
573      gp_debug_printf("] ");
574      gp_debug_printf("mech_attr_descs: [ ");
575 -    for (int i = 0; i < x->mech_attr_descs.mech_attr_descs_len; i++) {
576 +    for (unsigned i = 0; i < x->mech_attr_descs.mech_attr_descs_len; i++) {
577          gpdbg_gssx_mech_attr(&x->mech_attr_descs.mech_attr_descs_val[i]);
578      }
579      gp_debug_printf("] ");
580      gp_debug_printf("supported_extensions: [ ");
581 -    for (int i = 0;
582 +    for (unsigned i = 0;
583           i < x->supported_extensions.supported_extensions_len; i++) {
584          gpdbg_gssx_buffer(
585              &x->supported_extensions.supported_extensions_val[i]);
586 @@ -602,7 +602,7 @@ void gpdbg_gssx_arg_wrap(gssx_arg_wrap *x)
587      gp_debug_printf("conf_req: ");
588      gp_debug_printf("%d ", (int)x->conf_req);
589      gp_debug_printf("message_buffer: [ ");
590 -    for (int i = 0; i < x->message_buffer.message_buffer_len; i++) {
591 +    for (unsigned i = 0; i < x->message_buffer.message_buffer_len; i++) {
592          gpdbg_octet_string(&x->message_buffer.message_buffer_val[i]);
593      }
594      gp_debug_printf("] ");
595 @@ -618,7 +618,7 @@ void gpdbg_gssx_res_wrap(gssx_res_wrap *x)
596      gp_debug_printf("context_handle: ");
597      GPRPCDEBUG(gssx_ctx, x->context_handle);
598      gp_debug_printf("token_buffer: [ ");
599 -    for (int i = 0; i < x->token_buffer.token_buffer_len; i++) {
600 +    for (unsigned i = 0; i < x->token_buffer.token_buffer_len; i++) {
601          gpdbg_octet_string(&x->token_buffer.token_buffer_val[i]);
602      }
603      gp_debug_printf("] ");
604 @@ -640,7 +640,7 @@ void gpdbg_gssx_arg_unwrap(gssx_arg_unwrap *x)
605      gp_debug_printf("context_handle: ");
606      gpdbg_gssx_ctx(&x->context_handle);
607      gp_debug_printf("token_buffer: [ ");
608 -    for (int i = 0; i < x->token_buffer.token_buffer_len; i++) {
609 +    for (unsigned i = 0; i < x->token_buffer.token_buffer_len; i++) {
610          gpdbg_octet_string(&x->token_buffer.token_buffer_val[i]);
611      }
612      gp_debug_printf("] ");
613 @@ -656,7 +656,7 @@ void gpdbg_gssx_res_unwrap(gssx_res_unwrap *x)
614      gp_debug_printf("context_handle: ");
615      GPRPCDEBUG(gssx_ctx, x->context_handle);
616      gp_debug_printf("message_buffer: [ ");
617 -    for (int i = 0; i < x->message_buffer.message_buffer_len; i++) {
618 +    for (unsigned i = 0; i < x->message_buffer.message_buffer_len; i++) {
619          gpdbg_octet_string(&x->message_buffer.message_buffer_val[i]);
620      }
621      gp_debug_printf("] ");
622 diff --git a/proxy/src/gp_rpc_indicate_mechs.c b/proxy/src/gp_rpc_indicate_mechs.c
623 index 8abbc7f..6ae6756 100644
624 --- a/proxy/src/gp_rpc_indicate_mechs.c
625 +++ b/proxy/src/gp_rpc_indicate_mechs.c
626 @@ -25,8 +25,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
627      uint32_t ret_maj;
628      uint32_t ret_min;
629      int present;
630 -    int h, i, j;
631 -    int ret;
632 +     int ret;
633  
634      ima = &arg->indicate_mechs;
635      imr = &res->indicate_mechs;
636 @@ -53,8 +52,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
637      }
638      imr->mechs.mechs_len = mech_set->count;
639  
640 -    for (i = 0, h = 0; i < mech_set->count; i++, h++) {
641 -
642 +    for (unsigned i = 0, h = 0; i < mech_set->count; i++, h++) {
643          mi = &imr->mechs.mechs_val[h];
644  
645          ret = gp_conv_oid_to_gssx(&mech_set->elements[i], &mi->mech);
646 @@ -104,8 +102,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
647              ret_min = ret;
648              goto done;
649          }
650 -        for (j = 0; j < mech_attrs->count; j++) {
651 -
652 +        for (unsigned j = 0; j < mech_attrs->count; j++) {
653              ret_maj = gss_test_oid_set_member(&ret_min,
654                                                &mech_attrs->elements[j],
655                                                attr_set,
656 @@ -136,8 +133,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
657              goto done;
658          }
659  
660 -        for (j = 0; j < known_mech_attrs->count; j++) {
661 -
662 +        for (unsigned j = 0; j < known_mech_attrs->count; j++) {
663              ret_maj = gss_test_oid_set_member(&ret_min,
664                                                &known_mech_attrs->elements[j],
665                                                attr_set,
666 @@ -205,8 +201,7 @@ int gp_indicate_mechs(struct gp_call_ctx *gpcall UNUSED,
667      }
668      imr->mech_attr_descs.mech_attr_descs_len = attr_set->count;
669  
670 -    for (i = 0; i < attr_set->count; i++) {
671 -
672 +    for (unsigned i = 0; i < attr_set->count; i++) {
673          ma = &imr->mech_attr_descs.mech_attr_descs_val[i];
674  
675          ret = gp_conv_oid_to_gssx(&attr_set->elements[i], &ma->attr);
676 diff --git a/proxy/src/gp_socket.c b/proxy/src/gp_socket.c
677 index 829ff21..17ecf7c 100644
678 --- a/proxy/src/gp_socket.c
679 +++ b/proxy/src/gp_socket.c
680 @@ -303,7 +303,7 @@ static void gp_socket_read(verto_ctx *vctx, verto_ev *ev)
681      struct gp_buffer *rbuf;
682      uint32_t size;
683      bool header = false;
684 -    size_t rn;
685 +    ssize_t rn;
686      int ret;
687      int fd;
688  
689 @@ -487,7 +487,7 @@ static void gp_socket_write(verto_ctx *vctx, verto_ev *ev)
690          return;
691      }
692      if (vecs == 2) {
693 -        if (wn < sizeof(size)) {
694 +        if (wn < (ssize_t) sizeof(size)) {
695              /* don't bother trying to handle sockets that can't
696               * buffer even 4 bytes */
697              gp_conn_free(wbuf->conn);
698 diff --git a/proxy/src/gp_util.c b/proxy/src/gp_util.c
699 index ca83eb3..f158b84 100644
700 --- a/proxy/src/gp_util.c
701 +++ b/proxy/src/gp_util.c
702 @@ -109,7 +109,7 @@ char *gp_strerror(int errnum)
703  ssize_t gp_safe_read(int fd, void *buf, size_t count)
704  {
705      char *b = (char *)buf;
706 -    ssize_t len = 0;
707 +    size_t len = 0;
708      ssize_t ret;
709  
710      do {
711 @@ -128,7 +128,7 @@ ssize_t gp_safe_read(int fd, void *buf, size_t count)
712  ssize_t gp_safe_write(int fd, const void *buf, size_t count)
713  {
714      const char *b = (const char *)buf;
715 -    ssize_t len = 0;
716 +    size_t len = 0;
717      ssize_t ret;
718  
719      do {
720 diff --git a/proxy/tests/t_utils.c b/proxy/tests/t_utils.c
721 index 6af9a16..36f7bd1 100644
722 --- a/proxy/tests/t_utils.c
723 +++ b/proxy/tests/t_utils.c
724 @@ -8,7 +8,7 @@
725  int t_send_buffer(int fd, char *buf, uint32_t len)
726  {
727      uint32_t size;
728 -    size_t wn;
729 +    ssize_t wn;
730      size_t pos;
731  
732      size = htonl(len);
733 @@ -36,7 +36,7 @@ int t_send_buffer(int fd, char *buf, uint32_t len)
734  int t_recv_buffer(int fd, char *buf, uint32_t *len)
735  {
736      uint32_t size;
737 -    size_t rn;
738 +    ssize_t rn;
739      size_t pos;
740  
741      rn = read(fd, &size, sizeof(uint32_t));