krb5 commit: Remove unnecessary null checks

Greg Hudson ghudson at mit.edu
Wed Mar 29 13:03:49 EDT 2017


https://github.com/krb5/krb5/commit/07907bc4b9057001b0f0a117b80eac971823abbe
commit 07907bc4b9057001b0f0a117b80eac971823abbe
Author: Martin Kittel <martin.kittel at sap.com>
Date:   Wed Mar 29 08:55:57 2017 +0200

    Remove unnecessary null checks
    
    Remove some null checks for values that should never be null.  These
    checks were performed inconsistently and triggered static code
    analysis tools.

 src/lib/gssapi/krb5/naming_exts.c |   21 +++++++--------------
 src/lib/krb5/krb/preauth2.c       |    2 +-
 src/lib/krb5/rcache/ser_rc.c      |    2 +-
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/src/lib/gssapi/krb5/naming_exts.c b/src/lib/gssapi/krb5/naming_exts.c
index 0edb4b8..5f00efe 100644
--- a/src/lib/gssapi/krb5/naming_exts.c
+++ b/src/lib/gssapi/krb5/naming_exts.c
@@ -261,8 +261,7 @@ krb5_gss_inquire_name(OM_uint32 *minor_status,
     krb5_gss_name_t kname;
     krb5_data *kattrs = NULL;
 
-    if (minor_status != NULL)
-        *minor_status = 0;
+    *minor_status = 0;
 
     if (attrs != NULL)
         *attrs = GSS_C_NO_BUFFER_SET;
@@ -322,8 +321,7 @@ krb5_gss_get_name_attribute(OM_uint32 *minor_status,
     krb5_data kvalue = empty_data();
     krb5_data kdisplay_value = empty_data();
 
-    if (minor_status != NULL)
-        *minor_status = 0;
+    *minor_status = 0;
 
     code = krb5_gss_init_context(&context);
     if (code != 0) {
@@ -393,8 +391,7 @@ krb5_gss_set_name_attribute(OM_uint32 *minor_status,
     krb5_data kattr;
     krb5_data kvalue;
 
-    if (minor_status != NULL)
-        *minor_status = 0;
+    *minor_status = 0;
 
     code = krb5_gss_init_context(&context);
     if (code != 0) {
@@ -443,8 +440,7 @@ krb5_gss_delete_name_attribute(OM_uint32 *minor_status,
     krb5_gss_name_t kname;
     krb5_data kattr;
 
-    if (minor_status != NULL)
-        *minor_status = 0;
+    *minor_status = 0;
 
     code = krb5_gss_init_context(&context);
     if (code != 0) {
@@ -490,8 +486,7 @@ krb5_gss_map_name_to_any(OM_uint32 *minor_status,
     krb5_gss_name_t kname;
     char *kmodule;
 
-    if (minor_status != NULL)
-        *minor_status = 0;
+    *minor_status = 0;
 
     code = krb5_gss_init_context(&context);
     if (code != 0) {
@@ -542,8 +537,7 @@ krb5_gss_release_any_name_mapping(OM_uint32 *minor_status,
     krb5_gss_name_t kname;
     char *kmodule;
 
-    if (minor_status != NULL)
-        *minor_status = 0;
+    *minor_status = 0;
 
     code = krb5_gss_init_context(&context);
     if (code != 0) {
@@ -598,8 +592,7 @@ krb5_gss_export_name_composite(OM_uint32 *minor_status,
     unsigned char *cp;
     size_t princlen;
 
-    if (minor_status != NULL)
-        *minor_status = 0;
+    *minor_status = 0;
 
     code = krb5_gss_init_context(&context);
     if (code != 0) {
diff --git a/src/lib/krb5/krb/preauth2.c b/src/lib/krb5/krb/preauth2.c
index 17f2133..21aeff2 100644
--- a/src/lib/krb5/krb/preauth2.c
+++ b/src/lib/krb5/krb/preauth2.c
@@ -497,7 +497,7 @@ responder_get_answer(krb5_context context, krb5_clpreauth_rock rock,
     krb5_init_creds_context ctx = (krb5_init_creds_context)rock;
 
     /* Don't let plugins get the raw password. */
-    if (question && strcmp(KRB5_RESPONDER_QUESTION_PASSWORD, question) == 0)
+    if (strcmp(KRB5_RESPONDER_QUESTION_PASSWORD, question) == 0)
         return NULL;
     return k5_response_items_get_answer(ctx->rctx.items, question);
 }
diff --git a/src/lib/krb5/rcache/ser_rc.c b/src/lib/krb5/rcache/ser_rc.c
index 556af21..5c537f0 100644
--- a/src/lib/krb5/rcache/ser_rc.c
+++ b/src/lib/krb5/rcache/ser_rc.c
@@ -72,7 +72,7 @@ krb5_rcache_size(krb5_context kcontext, krb5_pointer arg, size_t *sizep)
          *      krb5_int32      for KV5M_RCACHE
          */
         required = sizeof(krb5_int32) * 3;
-        if (rcache->ops && rcache->ops->type)
+        if (rcache->ops)
             required += (strlen(rcache->ops->type)+1);
 
         /*


More information about the cvs-krb5 mailing list