krb5 commit: Remove tautological comparisons

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/1a8b805fc18c9b3865d472e765e19420d60348b6
commit 1a8b805fc18c9b3865d472e765e19420d60348b6
Author: Robbie Harwood <[email protected]>
Date:   Thu Feb 16 17:20:38 2017 -0500

    Remove tautological comparisons

 src/kadmin/server/schpw.c            |    2 +-
 src/lib/crypto/builtin/des/destest.c |    3 ++-
 src/lib/kdb/kdb_convert.c            |    4 ++--
 src/util/support/threads.c           |    6 ------
 4 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/kadmin/server/schpw.c b/src/kadmin/server/schpw.c
index 900adf7..2823057 100644
--- a/src/kadmin/server/schpw.c
+++ b/src/kadmin/server/schpw.c
@@ -366,7 +366,7 @@ chpwfail:
            to mk_error do. */
         krberror.error = ret;
         krberror.error -= ERROR_TABLE_BASE_krb5;
-        if (krberror.error < 0 || krberror.error > KRB_ERR_MAX)
+        if (krberror.error > KRB_ERR_MAX)
             krberror.error = KRB_ERR_GENERIC;
 
         krberror.client = NULL;
diff --git a/src/lib/crypto/builtin/des/destest.c b/src/lib/crypto/builtin/des/destest.c
index 6eeb070..dd2f68e 100644
--- a/src/lib/crypto/builtin/des/destest.c
+++ b/src/lib/crypto/builtin/des/destest.c
@@ -52,6 +52,7 @@
 /* Test a DES implementation against known inputs & outputs. */
 
 #include "des_int.h"
+#include <ctype.h>
 #include <stdio.h>
 
 void convert (char *, unsigned char []);
@@ -160,7 +161,7 @@ convert(text, cblock)
 {
     register int i;
     for (i = 0; i < 8; i++) {
-        if (text[i*2] < 0 || text[i*2] >= 128)
+        if (!isascii((unsigned char)text[i * 2]))
             abort ();
         if (value[(int) text[i*2]] == -1 || value[(int) text[i*2+1]] == -1) {
             printf("Bad value byte %d in %s\n", i, text);
diff --git a/src/lib/kdb/kdb_convert.c b/src/lib/kdb/kdb_convert.c
index 8172e9d..691635e 100644
--- a/src/lib/kdb/kdb_convert.c
+++ b/src/lib/kdb/kdb_convert.c
@@ -228,7 +228,7 @@ conv_princ_2ulog(krb5_principal princ, kdb_incr_update_t *upd,
 static void
 set_from_utf8str(krb5_data *d, utf8str_t u)
 {
-    if (u.utf8str_t_len > INT_MAX-1 || u.utf8str_t_len >= SIZE_MAX-1) {
+    if (u.utf8str_t_len > INT_MAX - 1) {
         d->data = NULL;
         return;
     }
@@ -419,7 +419,7 @@ ulog_conv_2logentry(krb5_context context, krb5_db_entry *entry,
             break;
 
         case AT_FAIL_AUTH_COUNT:
-            if (!exclude_nra && entry->fail_auth_count >= (krb5_kvno)0) {
+            if (!exclude_nra) {
                 ULOG_ENTRY_TYPE(update, ++final).av_type =
                     AT_FAIL_AUTH_COUNT;
                 ULOG_ENTRY(update, final).av_fail_auth_count =
diff --git a/src/util/support/threads.c b/src/util/support/threads.c
index bb8e287..be7e4c2 100644
--- a/src/util/support/threads.c
+++ b/src/util/support/threads.c
@@ -237,7 +237,6 @@ void *k5_getspecific (k5_key_t keynum)
     if (err)
         return NULL;
 
-    assert(keynum >= 0 && keynum < K5_KEY_MAX);
     assert(destructors_set[keynum] == 1);
 
 #ifndef ENABLE_THREADS
@@ -271,7 +270,6 @@ int k5_setspecific (k5_key_t keynum, void *value)
     if (err)
         return err;
 
-    assert(keynum >= 0 && keynum < K5_KEY_MAX);
     assert(destructors_set[keynum] == 1);
 
 #ifndef ENABLE_THREADS
@@ -334,8 +332,6 @@ int k5_key_register (k5_key_t keynum, void (*destructor)(void *))
     if (err)
         return err;
 
-    assert(keynum >= 0 && keynum < K5_KEY_MAX);
-
 #ifndef ENABLE_THREADS
 
     assert(destructors_set[keynum] == 0);
@@ -365,8 +361,6 @@ int k5_key_register (k5_key_t keynum, void (*destructor)(void *))
 
 int k5_key_delete (k5_key_t keynum)
 {
-    assert(keynum >= 0 && keynum < K5_KEY_MAX);
-
 #ifndef ENABLE_THREADS
 
     assert(destructors_set[keynum] == 1);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.