Bug 1280844 - Remove some redundant null checks in lib/. r=mt.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 21 Jun 2016 09:59:17 +1000
changeset 12282 839ebb15e92fb57c6d5d4fc16205f22811e0f188
parent 12281 1d90aaeb3df8042c68c4452a2b5757e1a65e0674
child 12283 89779ff5d079067f9e31c697eff65dc72028af34
push id1322
push usermartin.thomson@gmail.com
push dateTue, 21 Jun 2016 02:23:15 +0000
reviewersmt
bugs1280844
Bug 1280844 - Remove some redundant null checks in lib/. r=mt. MozReview-Commit-ID: 7fYJMjQyHQb
lib/crmf/servget.c
lib/softoken/legacydb/dbmshim.c
lib/softoken/legacydb/lgattr.c
lib/softoken/pkcs11u.c
--- a/lib/crmf/servget.c
+++ b/lib/crmf/servget.c
@@ -491,19 +491,17 @@ crmf_copy_cert_req_msg(CRMFCertReqMsg *s
         goto loser;
     }
     /* None of my set/get routines operate on the regInfo field, so
      * for now, that won't get copied over.
      */
     return newReqMsg;
 
 loser:
-    if (newReqMsg != NULL) {
-        CRMF_DestroyCertReqMsg(newReqMsg);
-    }
+    CRMF_DestroyCertReqMsg(newReqMsg);
     return NULL;
 }
 
 CRMFCertReqMsg *
 CRMF_CertReqMessagesGetCertReqMsgAtIndex(CRMFCertReqMessages *inReqMsgs,
                                          int index)
 {
     int numMsgs;
@@ -863,19 +861,17 @@ CRMF_CertRequestGetControlAtIndex(CRMFCe
         default:
             rv = SECFailure;
     }
     if (rv != SECSuccess) {
         goto loser;
     }
     return newControl;
 loser:
-    if (newControl != NULL) {
-        CRMF_DestroyControl(newControl);
-    }
+    CRMF_DestroyControl(newControl);
     return NULL;
 }
 
 static SECItem *
 crmf_copy_control_value(CRMFControl *inControl)
 {
     return SECITEM_DupItem(&inControl->derValue);
 }
--- a/lib/softoken/legacydb/dbmshim.c
+++ b/lib/softoken/legacydb/dbmshim.c
@@ -598,16 +598,14 @@ dbsopen(const char *dbname, int flags, i
     dbs->sync = dbs_sync;
     dbs->fd = dbs_fd;
 
     return dbs;
 loser:
     if (db) {
 	(*db->close)(db);
     }
-    if (dbsp) {
-	if (dbsp->blobdir) {
-	    PORT_Free(dbsp->blobdir);
-	}
-	PORT_Free(dbsp);
+    if (dbsp->blobdir) {
+        PORT_Free(dbsp->blobdir);
     }
+    PORT_Free(dbsp);
     return NULL;
 }
--- a/lib/softoken/legacydb/lgattr.c
+++ b/lib/softoken/legacydb/lgattr.c
@@ -66,21 +66,18 @@ lg_NewObjectCache(SDB *sdb, const SECIte
     rv = SECITEM_CopyItem(NULL,&obj->dbKey,dbKey);
     lg_DBUnlock(sdb);
     if (rv != SECSuccess) {
 	goto loser;
     }
 
     return obj;
 loser:
-    if (obj) {
-	(void) lg_DestroyObjectCache(obj);
-    }
+    (void) lg_DestroyObjectCache(obj);
     return NULL;
-
 }
 
 /*
  * free all the data associated with an object. Object reference count must
  * be 'zero'.
  */
 static void
 lg_DestroyObjectCache(LGObjectCache *obj)
--- a/lib/softoken/pkcs11u.c
+++ b/lib/softoken/pkcs11u.c
@@ -1924,21 +1924,18 @@ sftk_NewTokenObject(SFTKSlot *slot, SECI
     }
     if (object->refLock == NULL) {
 	goto loser;
     }
     object->refCount = 1;
 
     return object;
 loser:
-    if (object) {
-	(void) sftk_DestroyObject(object);
-    }
+    (void) sftk_DestroyObject(object);
     return NULL;
-
 }
 
 SFTKTokenObject *
 sftk_convertSessionToToken(SFTKObject *obj)
 {
     SECItem *key;
     SFTKSessionObject *so = (SFTKSessionObject *)obj;
     SFTKTokenObject *to = sftk_narrowToTokenObject(obj);