]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Remove spurious NULL checks
authorBen Kaduk <kaduk@mit.edu>
Wed, 11 Feb 2015 22:47:10 +0000 (17:47 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Thu, 28 May 2015 12:51:00 +0000 (08:51 -0400)
clang 3.5 is more aggressive about these checks than the previous
FreeBSD system compiler, so new warnings (which became errors)
appeared on FreeBSD 11-CURRENT.

In afs_dcache.c, checking &tdc->f for NULL-ness has no effect.
The struct fcache f member of struct dcache is an ordinary structure
element; its address will be the value of tdc plus the offset of
f within struct dcache, which will not be NULL even if tdc is NULL.

In ubik_db_if.c, udbHandle is a file-scope global and thus has
allocated storage; the address of a member variable will never
be NULL.  The 0 it was compared against was spelled RX_SECIDX_NULL,
which shows the intended check, which is for the value of the
uh_scIndex member variable, not its address.

In afscp_server.c, srv->conns can never be NULL since conns is a member
variable of struct afscp_server (of array type, containing pointers
to struct rx_connection).  Comparing the array member variable against
NULL is comparing the address of the array, which is never NULL since
it is not allocated separately from struct afscp_server.

In fssync-debug.c, state.vop->partName is never NULL because
common_volop_prolog always allocates for state.vop, and the
partName member variable of struct fssync_state is of array type,
and thus is not separately allocated from the containing structure.

Reviewed-on: http://gerrit.openafs.org/11739
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit fb499c2406450fa5dc423a0b038266d3b8e79e33)

Change-Id: I13799a3362508672136f8c603eabdfc0f3ee072d
Reviewed-on: http://gerrit.openafs.org/11843
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/afs/afs_dcache.c
src/bucoord/ubik_db_if.c
src/libafscp/afscp_server.c
src/vol/fssync-debug.c

index a156e22ed4599db449057252cf3f8b8d6bb64df5..c05393c15fc7ee1b574cbe2152627df628a66e21 100644 (file)
@@ -2926,14 +2926,12 @@ afs_UFSGetDSlot(afs_int32 aslot, int indexvalid, int datavalid)
        tdc->f.states &= ~(DRO|DBackup|DRW);
        afs_DCMoveBucket(tdc, 0, 0);
     } else {
-       if (&tdc->f != 0) {
-           if (tdc->f.states & DRO) {
-               afs_DCMoveBucket(tdc, 0, 2);
-           } else if (tdc->f.states & DBackup) {
-               afs_DCMoveBucket(tdc, 0, 1);
-           } else {
-               afs_DCMoveBucket(tdc, 0, 1);
-           }
+       if (tdc->f.states & DRO) {
+           afs_DCMoveBucket(tdc, 0, 2);
+       } else if (tdc->f.states & DBackup) {
+           afs_DCMoveBucket(tdc, 0, 1);
+       } else {
+           afs_DCMoveBucket(tdc, 0, 1);
        }
     }
     tdc->refCount = 1;
index e29e8f9ba16ac0df4495178ff141d0c060f6195c..9be620312b9fb9f5713cc19622418d98fa8fa929 100644 (file)
@@ -907,7 +907,7 @@ udbClientInit(int noAuthFlag, int localauth, char *cellName)
        afs_com_err(whoami, code, "(configuring connection security)");
        ERROR(BC_NOCELLCONFIG);
     }
-    if (&udbHandle.uh_scIndex == RX_SECIDX_NULL && !noAuthFlag)
+    if (udbHandle.uh_scIndex == RX_SECIDX_NULL && !noAuthFlag)
        afs_com_err(whoami, 0, "Can't get tokens - running unauthenticated");
 
     /* We have to have space for the trailing NULL that terminates the server
index 2b08e69f67b2723d1193e5a4d89b2956f133fa8a..a5fb47d0044f44a839e590fc4924f286fa890288 100644 (file)
@@ -474,7 +474,7 @@ afscp_ServerByIndex(int i)
 struct rx_connection *
 afscp_ServerConnection(const struct afscp_server *srv, int i)
 {
-    if (srv == NULL || srv->conns == NULL)
+    if (srv == NULL)
        return NULL;
     if (i >= srv->naddrs || i < 0)
        return NULL;
index 61cd76cb6cd689a5dbb317e462d5b1b5ee53e8af..e974b09b25efe17644bf1cba9abbc05ca65420ae 100644 (file)
@@ -459,7 +459,7 @@ VolOnline(struct cmd_syndesc * as, void * rock)
     common_prolog(as, &state);
     common_volop_prolog(as, &state);
 
-    if (state.vop->partName==0 || *(state.vop->partName)==0) {
+    if (*(state.vop->partName)==0) {
        fprintf(stderr, "required argument -partition not given\n");
        return -1;
     }