krb5 commit: Minor cleanups relating to size_t being unsigned

Benjamin Kaduk kaduk at MIT.EDU
Tue Jul 3 00:43:53 EDT 2012


https://github.com/krb5/krb5/commit/149883bec140286d19751fbae7550043f754f4bb
commit 149883bec140286d19751fbae7550043f754f4bb
Author: Ben Kaduk <kaduk at mit.edu>
Date:   Wed Jun 27 16:35:20 2012 -0400

    Minor cleanups relating to size_t being unsigned
    
    In order to use -1 as a sentinel value, we should explicitly cast
    to make it clear what we are doing.  It might be better to use
    a less convoluted sentinel value such as SIZE_T_MAX, though.
    
    Additionally, since size_t is unsigned and at least as wide as
    an int, a loop with int index variable that compares against a
    size_t for its termination check could become an infinite loop.
    Make the loop index size_t for consistency.

 src/plugins/kdb/db2/libdb2/hash/hash_bigkey.c |    2 +-
 src/tests/gss-threads/gss-misc.c              |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/plugins/kdb/db2/libdb2/hash/hash_bigkey.c b/src/plugins/kdb/db2/libdb2/hash/hash_bigkey.c
index 6874f47..e6aa035 100644
--- a/src/plugins/kdb/db2/libdb2/hash/hash_bigkey.c
+++ b/src/plugins/kdb/db2/libdb2/hash/hash_bigkey.c
@@ -277,7 +277,7 @@ __big_keydata(hashp, pagep, key, val, ndx)
 	key->data = hashp->bigkey_buf;
 	__put_page(hashp, key_pagep, A_RAW, 0);
 
-	if (key->size == -1)
+	if (key->size == (size_t)-1)
 		return (-1);
 
 	/* Create an item_info to direct __big_return to the beginning pgno. */
diff --git a/src/tests/gss-threads/gss-misc.c b/src/tests/gss-threads/gss-misc.c
index e52ae28..4fdbde3 100644
--- a/src/tests/gss-threads/gss-misc.c
+++ b/src/tests/gss-threads/gss-misc.c
@@ -386,7 +386,7 @@ void display_ctx_flags(flags)
 void print_token(tok)
      gss_buffer_t tok;
 {
-    int i;
+    size_t i;
     unsigned char *p = tok->value;
 
     if (!display_file)


More information about the cvs-krb5 mailing list