Bug 1368107 - Remove fallible version of TransportSecurityInfo::GetPort(). r=keeler draft
authorCykesiopka <cykesiopka.bmo@gmail.com>
Sat, 03 Jun 2017 13:36:04 +0800
changeset 588579 88f511d730bb02b5e28a86cb366ae1c915e0a8b1
parent 588578 da257f5fba2c26cd92d932c3d1d363458b84a65b
child 588580 95c8e9ca6d74d04f2836aea2bcdb1c751d3e9308
push id62093
push usercykesiopka.bmo@gmail.com
push dateSat, 03 Jun 2017 07:38:34 +0000
reviewerskeeler
bugs1368107
milestone55.0a1
Bug 1368107 - Remove fallible version of TransportSecurityInfo::GetPort(). r=keeler The function is infallible in pratice, and so is unnecessary when there's an actual infallible version. MozReview-Commit-ID: FTuVyqwjZ8O
security/manager/ssl/SSLServerCertVerification.cpp
security/manager/ssl/TransportSecurityInfo.cpp
security/manager/ssl/TransportSecurityInfo.h
security/manager/ssl/nsNSSIOLayer.cpp
--- a/security/manager/ssl/SSLServerCertVerification.cpp
+++ b/security/manager/ssl/SSLServerCertVerification.cpp
@@ -532,18 +532,17 @@ CertErrorRunnable::CheckCertOverrides()
   Unused << mFdForLogging;
 
   if (!NS_IsMainThread()) {
     NS_ERROR("CertErrorRunnable::CheckCertOverrides called off main thread");
     return new SSLServerCertVerificationResult(mInfoObject,
                                                mDefaultErrorCodeToReport);
   }
 
-  int32_t port;
-  mInfoObject->GetPort(&port);
+  int32_t port = mInfoObject->GetPort();
 
   nsAutoCString hostWithPortString(mInfoObject->GetHostName());
   hostWithPortString.Append(':');
   hostWithPortString.AppendInt(port);
 
   uint32_t remaining_display_errors = mCollectedErrors;
 
   bool overrideAllowed;
--- a/security/manager/ssl/TransportSecurityInfo.cpp
+++ b/security/manager/ssl/TransportSecurityInfo.cpp
@@ -79,23 +79,16 @@ TransportSecurityInfo::SetHostName(const
 nsresult
 TransportSecurityInfo::SetPort(int32_t aPort)
 {
   mPort = aPort;
   return NS_OK;
 }
 
 nsresult
-TransportSecurityInfo::GetPort(int32_t *aPort)
-{
-  *aPort = mPort;
-  return NS_OK;
-}
-
-nsresult
 TransportSecurityInfo::SetOriginAttributes(
   const OriginAttributes& aOriginAttributes)
 {
   mOriginAttributes = aOriginAttributes;
   return NS_OK;
 }
 
 PRErrorCode
@@ -943,25 +936,19 @@ RememberCertErrorsTable::RememberCertErr
 static nsresult
 GetHostPortKey(TransportSecurityInfo* infoObject, /*out*/ nsCString& result)
 {
   MOZ_ASSERT(infoObject);
   NS_ENSURE_ARG(infoObject);
 
   result.Truncate();
 
-  int32_t port;
-  nsresult rv = infoObject->GetPort(&port);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
   result.Assign(infoObject->GetHostName());
   result.Append(':');
-  result.AppendInt(port);
+  result.AppendInt(infoObject->GetPort());
 
   return NS_OK;
 }
 
 void
 RememberCertErrorsTable::RememberCertHasError(TransportSecurityInfo* infoObject,
                                               nsSSLStatus* status,
                                               SECStatus certVerificationResult)
--- a/security/manager/ssl/TransportSecurityInfo.h
+++ b/security/manager/ssl/TransportSecurityInfo.h
@@ -54,17 +54,16 @@ public:
 
   nsresult SetSecurityState(uint32_t aState);
 
   const nsACString & GetHostName() const { return mHostName; }
 
   void SetHostName(const char* host);
 
   int32_t GetPort() const { return mPort; }
-  nsresult GetPort(int32_t *aPort);
   nsresult SetPort(int32_t aPort);
 
   const OriginAttributes& GetOriginAttributes() const {
     return mOriginAttributes;
   }
   nsresult SetOriginAttributes(const OriginAttributes& aOriginAttributes);
 
   PRErrorCode GetErrorCode() const;
--- a/security/manager/ssl/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/nsNSSIOLayer.cpp
@@ -2250,19 +2250,16 @@ ClientAuthDataRunnable::RunOnTargetThrea
         }
       }
 
       if (CERT_LIST_END(CERT_LIST_HEAD(certList), certList)) {
         // list is empty - no matching certs
         goto loser;
       }
 
-      int32_t port;
-      mSocketInfo->GetPort(&port);
-
       UniquePORTString corg(CERT_GetOrgName(&mServerCert->subject));
       nsAutoCString org(corg.get());
 
       UniquePORTString cissuer(CERT_GetOrgName(&mServerCert->issuer));
       nsAutoCString issuer(cissuer.get());
 
       nsCOMPtr<nsIMutableArray> certArray = nsArrayBase::Create();
       if (!certArray) {
@@ -2289,17 +2286,18 @@ ClientAuthDataRunnable::RunOnTargetThrea
                          NS_CLIENTAUTHDIALOGS_CONTRACTID);
 
       if (NS_FAILED(rv)) {
         goto loser;
       }
 
       uint32_t selectedIndex = 0;
       bool certChosen = false;
-      rv = dialogs->ChooseCertificate(mSocketInfo, hostname, port, org, issuer,
+      rv = dialogs->ChooseCertificate(mSocketInfo, hostname,
+                                      mSocketInfo->GetPort(), org, issuer,
                                       certArray, &selectedIndex, &certChosen);
       if (NS_FAILED(rv)) {
         goto loser;
       }
 
       // even if the user has canceled, we want to remember that, to avoid repeating prompts
       bool wantRemember = false;
       mSocketInfo->GetRememberClientAuthCertificate(&wantRemember);