Bug 1280844 - Remove some redundant null checks in lib/. r?mt. draft
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 21 Jun 2016 09:59:17 +1000
changeset 380171 cb51d2f903ca1ceda8461644289df0da4d4ab67b
parent 380170 f715f0bb465f9925ecd19d6fca66093147e6401e
child 380172 26f0266070d50811a7d98c90ab92797f272d860c
push id21158
push usernnethercote@mozilla.com
push dateMon, 20 Jun 2016 23:59:39 +0000
reviewersmt
bugs1280844
milestone50.0a1
Bug 1280844 - Remove some redundant null checks in lib/. r?mt. MozReview-Commit-ID: 7fYJMjQyHQb
security/nss/lib/crmf/servget.c
security/nss/lib/softoken/legacydb/dbmshim.c
security/nss/lib/softoken/legacydb/lgattr.c
security/nss/lib/softoken/pkcs11u.c
--- a/security/nss/lib/crmf/servget.c
+++ b/security/nss/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/security/nss/lib/softoken/legacydb/dbmshim.c
+++ b/security/nss/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/security/nss/lib/softoken/legacydb/lgattr.c
+++ b/security/nss/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/security/nss/lib/softoken/pkcs11u.c
+++ b/security/nss/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);