src/kauth/krb_udp.c: Remove redundant NULL check for array address
authorAnders Kaseorg <andersk@mit.edu>
Sat, 1 Aug 2015 09:52:59 +0000 (05:52 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 2 Aug 2015 03:03:55 +0000 (23:03 -0400)
Resolves this warning with clang:

krb_udp.c:302:13: warning: address of array 'tentry.misc_auth_bytes' will always evaluate to 'true' [-Wpointer-bool-conversion]
        if (tentry.misc_auth_bytes) {
        ~~  ~~~~~~~^~~~~~~~~~~~~~~

Change-Id: I0656b055090654eada2cd63476330fb288490acc
Reviewed-on: http://gerrit.openafs.org/11964
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/kauth/krb_udp.c

index 88a37a0..d3e670e 100644 (file)
@@ -274,6 +274,11 @@ UDP_Authenticate(int ksoc, struct sockaddr_in *client, char *name,
     if (to) {                  /* if user exists check other stuff */
        afs_int32 sto;
        struct kaentry sentry;
+
+       unsigned char misc_auth_bytes[4];
+       afs_uint32 temp;        /* unsigned for safety */
+       afs_uint32 pwexpires;
+
        save_principal(udpAuthPrincipal, name, inst, 0);
 
        tgt = ((strcmp(sname, KA_TGS_NAME) == 0)
@@ -299,23 +304,17 @@ UDP_Authenticate(int ksoc, struct sockaddr_in *client, char *name,
            goto abort;
        }
 
-       if (tentry.misc_auth_bytes) {
-           unsigned char misc_auth_bytes[4];
-           afs_uint32 temp;    /* unsigned for safety */
-           afs_uint32 pwexpires;
-
-           memcpy(&temp, tentry.misc_auth_bytes, sizeof(afs_uint32));
-           temp = ntohl(temp);
-           unpack_long(temp, misc_auth_bytes);
-           pwexpires = misc_auth_bytes[0];
-           if (pwexpires) {
-               pwexpires =
-                   ntohl(tentry.change_password_time) +
-                   24 * 60 * 60 * pwexpires;
-               if (pwexpires < now) {
-                   code = KERB_ERR_AUTH_EXP;   /* was KAPWEXPIRED */
-                   goto abort;
-               }
+       memcpy(&temp, tentry.misc_auth_bytes, sizeof(afs_uint32));
+       temp = ntohl(temp);
+       unpack_long(temp, misc_auth_bytes);
+       pwexpires = misc_auth_bytes[0];
+       if (pwexpires) {
+           pwexpires =
+               ntohl(tentry.change_password_time) +
+               24 * 60 * 60 * pwexpires;
+           if (pwexpires < now) {
+               code = KERB_ERR_AUTH_EXP;       /* was KAPWEXPIRED */
+               goto abort;
            }
        }