Bug 1586456 - Unnecessary conditional in pki3hack, pk11load and stanpcertdb. r=jcj
authorMarcus Burghardt <mburghardt@mozilla.com>
Tue, 08 Oct 2019 00:32:05 +0000
changeset 15327 b34061c3a377061f9508615551c09c5f5b66d144
parent 15326 dc86215aea17672228b28cf3516da89a751cc24d
child 15328 c319019aee75914fcbc8df0a530de7114e81229b
push id3526
push userjjones@mozilla.com
push dateTue, 08 Oct 2019 00:32:27 +0000
reviewersjcj
bugs1586456
Bug 1586456 - Unnecessary conditional in pki3hack, pk11load and stanpcertdb. r=jcj Some conditionals that are always true were removed. Differential Revision: https://phabricator.services.mozilla.com/D48255
lib/certdb/stanpcertdb.c
lib/pk11wrap/pk11load.c
lib/pki/pki3hack.c
--- a/lib/certdb/stanpcertdb.c
+++ b/lib/certdb/stanpcertdb.c
@@ -407,28 +407,27 @@ CERT_NewTempCertificate(CERTCertDBHandle
     if (!cc) {
         CERT_MapStanError();
         goto loser;
     }
     nssItem_Create(c->object.arena, &c->issuer, cc->derIssuer.len,
                    cc->derIssuer.data);
     nssItem_Create(c->object.arena, &c->subject, cc->derSubject.len,
                    cc->derSubject.data);
-    if (PR_TRUE) {
-        /* CERTCertificate stores serial numbers decoded.  I need the DER
-        * here.  sigh.
-        */
-        SECItem derSerial = { 0 };
-        CERT_SerialNumberFromDERCert(&cc->derCert, &derSerial);
-        if (!derSerial.data)
-            goto loser;
-        nssItem_Create(c->object.arena, &c->serial, derSerial.len,
-                       derSerial.data);
-        PORT_Free(derSerial.data);
-    }
+    /* CERTCertificate stores serial numbers decoded.  I need the DER
+    * here.  sigh.
+    */
+    SECItem derSerial = { 0 };
+    CERT_SerialNumberFromDERCert(&cc->derCert, &derSerial);
+    if (!derSerial.data)
+        goto loser;
+    nssItem_Create(c->object.arena, &c->serial, derSerial.len,
+                   derSerial.data);
+    PORT_Free(derSerial.data);
+
     if (nickname) {
         c->object.tempName =
             nssUTF8_Create(c->object.arena, nssStringType_UTF8String,
                            (NSSUTF8 *)nickname, PORT_Strlen(nickname));
     }
     if (cc->emailAddr && cc->emailAddr[0]) {
         c->email = nssUTF8_Create(
             c->object.arena, nssStringType_PrintableString,
--- a/lib/pk11wrap/pk11load.c
+++ b/lib/pk11wrap/pk11load.c
@@ -483,22 +483,20 @@ secmod_LoadPKCS11Module(SECMODModule *mo
 
     /*
      * We need to get the function list
      */
     if ((*entry)((CK_FUNCTION_LIST_PTR *)&mod->functionList) != CKR_OK)
         goto fail;
 
 #ifdef DEBUG_MODULE
-    if (PR_TRUE) {
-        modToDBG = PR_GetEnvSecure("NSS_DEBUG_PKCS11_MODULE");
-        if (modToDBG && strcmp(mod->commonName, modToDBG) == 0) {
-            mod->functionList = (void *)nss_InsertDeviceLog(
-                (CK_FUNCTION_LIST_PTR)mod->functionList);
-        }
+    modToDBG = PR_GetEnvSecure("NSS_DEBUG_PKCS11_MODULE");
+    if (modToDBG && strcmp(mod->commonName, modToDBG) == 0) {
+        mod->functionList = (void *)nss_InsertDeviceLog(
+            (CK_FUNCTION_LIST_PTR)mod->functionList);
     }
 #endif
 
     mod->isThreadSafe = PR_TRUE;
 
     /* Now we initialize the module */
     rv = secmod_ModuleInit(mod, oldModule, &alreadyLoaded);
     if (rv != SECSuccess) {
--- a/lib/pki/pki3hack.c
+++ b/lib/pki/pki3hack.c
@@ -997,30 +997,29 @@ STAN_GetNSSCertificate(CERTCertificate *
         nssArena_Destroy(arena);
         return NULL;
     }
     c->object = *pkiob;
     nssItem_Create(arena,
                    &c->issuer, cc->derIssuer.len, cc->derIssuer.data);
     nssItem_Create(arena,
                    &c->subject, cc->derSubject.len, cc->derSubject.data);
-    if (PR_TRUE) {
-        /* CERTCertificate stores serial numbers decoded.  I need the DER
-        * here.  sigh.
-        */
-        SECItem derSerial;
-        SECStatus secrv;
-        secrv = CERT_SerialNumberFromDERCert(&cc->derCert, &derSerial);
-        if (secrv == SECFailure) {
-            nssArena_Destroy(arena);
-            return NULL;
-        }
-        nssItem_Create(arena, &c->serial, derSerial.len, derSerial.data);
-        PORT_Free(derSerial.data);
+    /* CERTCertificate stores serial numbers decoded.  I need the DER
+    * here.  sigh.
+    */
+    SECItem derSerial;
+    SECStatus secrv;
+    secrv = CERT_SerialNumberFromDERCert(&cc->derCert, &derSerial);
+    if (secrv == SECFailure) {
+        nssArena_Destroy(arena);
+        return NULL;
     }
+    nssItem_Create(arena, &c->serial, derSerial.len, derSerial.data);
+    PORT_Free(derSerial.data);
+
     if (cc->emailAddr && cc->emailAddr[0]) {
         c->email = nssUTF8_Create(arena,
                                   nssStringType_PrintableString,
                                   (NSSUTF8 *)cc->emailAddr,
                                   PORT_Strlen(cc->emailAddr));
     }
     if (cc->slot) {
         instance = nss_ZNEW(arena, nssCryptokiInstance);