mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1048070, Part 2: Remove uses of PR_NOT_REACHED and PR_ARRAY_SIZE in mozilla::pkix, r=keeeler
--HG-- extra : rebase_source : d373a7526c1048770bed8bacb7e14c8f10e832cb
This commit is contained in:
parent
a864fbe335
commit
bd6fa86a1a
@ -29,7 +29,6 @@
|
||||
|
||||
#include "pkix/nullptr.h"
|
||||
#include "pkix/Result.h"
|
||||
#include "prlog.h"
|
||||
#include "stdint.h"
|
||||
|
||||
namespace mozilla { namespace pkix {
|
||||
@ -283,8 +282,7 @@ public:
|
||||
Result GetInput(const Mark& mark, /*out*/ Input& item)
|
||||
{
|
||||
if (&mark.input != this || mark.mark > input) {
|
||||
PR_NOT_REACHED("invalid mark");
|
||||
return Result::FATAL_ERROR_INVALID_ARGS;
|
||||
return NotReached("invalid mark", Result::FATAL_ERROR_INVALID_ARGS);
|
||||
}
|
||||
return item.Init(mark.mark, static_cast<uint16_t>(input - mark.mark));
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
#ifndef mozilla_pkix__Result_h
|
||||
#define mozilla_pkix__Result_h
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "pkix/enumclass.h"
|
||||
|
||||
namespace mozilla { namespace pkix {
|
||||
@ -103,6 +105,13 @@ IsFatalError(Result rv)
|
||||
return static_cast<unsigned int>(rv) & FATAL_ERROR_FLAG;
|
||||
}
|
||||
|
||||
inline Result
|
||||
NotReached(const char* /*explanation*/, Result result)
|
||||
{
|
||||
assert(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
} } // namespace mozilla::pkix
|
||||
|
||||
#endif // mozilla_pkix__Result_h
|
||||
|
@ -97,8 +97,8 @@ PathBuildingStep::RecordResult(Result newResult, /*out*/ bool& keepGoing)
|
||||
|
||||
if (resultWasSet) {
|
||||
if (result == Success) {
|
||||
PR_NOT_REACHED("RecordResult called after finding a chain");
|
||||
return Result::FATAL_ERROR_INVALID_STATE;
|
||||
return NotReached("RecordResult called after finding a chain",
|
||||
Result::FATAL_ERROR_INVALID_STATE);
|
||||
}
|
||||
// If every potential issuer has the same problem (e.g. expired) and/or if
|
||||
// there is only one bad potential issuer, then return a more specific
|
||||
@ -240,8 +240,7 @@ BuildForward(TrustDomain& trustDomain,
|
||||
for (const BackCert* cert = &subject; cert; cert = cert->childCert) {
|
||||
rv = chain.Append(cert->GetDER());
|
||||
if (rv != Success) {
|
||||
PR_NOT_REACHED("NonOwningDERArray::SetItem failed.");
|
||||
return rv;
|
||||
return NotReached("NonOwningDERArray::SetItem failed.", rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,9 +194,9 @@ CertPolicyId::IsAnyPolicy() const {
|
||||
if (this == &CertPolicyId::anyPolicy) {
|
||||
return true;
|
||||
}
|
||||
return numBytes == PR_ARRAY_SIZE(::mozilla::pkix::anyPolicy) &&
|
||||
return numBytes == sizeof(::mozilla::pkix::anyPolicy) &&
|
||||
!memcmp(bytes, ::mozilla::pkix::anyPolicy,
|
||||
PR_ARRAY_SIZE(::mozilla::pkix::anyPolicy));
|
||||
sizeof(::mozilla::pkix::anyPolicy));
|
||||
}
|
||||
|
||||
// certificatePolicies ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation
|
||||
@ -524,12 +524,12 @@ MatchEKU(Reader& value, KeyPurposeId requiredEKU,
|
||||
break;
|
||||
|
||||
case KeyPurposeId::anyExtendedKeyUsage:
|
||||
PR_NOT_REACHED("anyExtendedKeyUsage should start with found==true");
|
||||
return Result::FATAL_ERROR_LIBRARY_FAILURE;
|
||||
return NotReached("anyExtendedKeyUsage should start with found==true",
|
||||
Result::FATAL_ERROR_LIBRARY_FAILURE);
|
||||
|
||||
default:
|
||||
PR_NOT_REACHED("unrecognized EKU");
|
||||
return Result::FATAL_ERROR_LIBRARY_FAILURE;
|
||||
return NotReached("unrecognized EKU",
|
||||
Result::FATAL_ERROR_LIBRARY_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,8 +418,8 @@ TimeChoice(Reader& tagged, uint8_t expectedTag, /*out*/ Time& time)
|
||||
}
|
||||
yearHi = yearLo >= 50u ? 19u : 20u;
|
||||
} else {
|
||||
PR_NOT_REACHED("invalid tag given to TimeChoice");
|
||||
return Result::ERROR_INVALID_TIME;
|
||||
return NotReached("invalid tag given to TimeChoice",
|
||||
Result::ERROR_INVALID_TIME);
|
||||
}
|
||||
unsigned int year = (yearHi * 100u) + yearLo;
|
||||
if (year < 1970u) {
|
||||
@ -474,8 +474,8 @@ TimeChoice(Reader& tagged, uint8_t expectedTag, /*out*/ Time& time)
|
||||
jul + aug + sep + oct + nov;
|
||||
break;
|
||||
default:
|
||||
PR_NOT_REACHED("month already bounds-checked by ReadTwoDigits");
|
||||
return Result::FATAL_ERROR_INVALID_STATE;
|
||||
return NotReached("month already bounds-checked by ReadTwoDigits",
|
||||
Result::FATAL_ERROR_INVALID_STATE);
|
||||
}
|
||||
|
||||
unsigned int dayOfMonth;
|
||||
|
@ -37,8 +37,6 @@
|
||||
// they are able to do so; otherwise they fail with the input mark in an
|
||||
// undefined state.
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "pkix/Input.h"
|
||||
#include "pkix/pkixtypes.h"
|
||||
|
||||
|
@ -323,8 +323,7 @@ VerifyEncodedOCSPResponse(TrustDomain& trustDomain, const struct CertID& certID,
|
||||
return Result::ERROR_OCSP_UNKNOWN_CERT;
|
||||
}
|
||||
|
||||
PR_NOT_REACHED("unknown CertStatus");
|
||||
return Result::ERROR_OCSP_UNKNOWN_CERT;
|
||||
return NotReached("unknown CertStatus", Result::ERROR_OCSP_UNKNOWN_CERT);
|
||||
}
|
||||
|
||||
// OCSPResponse ::= SEQUENCE {
|
||||
@ -888,7 +887,7 @@ CreateEncodedOCSPRequest(TrustDomain& trustDomain, const struct CertID& certID,
|
||||
+ 2 // requestList
|
||||
+ 2 // Request
|
||||
+ 2 // reqCert (CertID)
|
||||
+ PR_ARRAY_SIZE(hashAlgorithm) // hashAlgorithm
|
||||
+ sizeof(hashAlgorithm) // hashAlgorithm
|
||||
+ 2 + hashLen // issuerNameHash
|
||||
+ 2 + hashLen // issuerKeyHash
|
||||
+ 2; // serialNumber (header)
|
||||
@ -918,7 +917,7 @@ CreateEncodedOCSPRequest(TrustDomain& trustDomain, const struct CertID& certID,
|
||||
*d++ = 0x30; *d++ = totalLen - 10u; // reqCert (CertID SEQUENCE)
|
||||
|
||||
// reqCert.hashAlgorithm
|
||||
for (size_t i = 0; i < PR_ARRAY_SIZE(hashAlgorithm); ++i) {
|
||||
for (size_t i = 0; i < sizeof(hashAlgorithm); ++i) {
|
||||
*d++ = hashAlgorithm[i];
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ TEST_F(pkixder_input_tests, MarkAndGetInput)
|
||||
ASSERT_TRUE(InputsAreEqual(expected, item));
|
||||
}
|
||||
|
||||
// Cannot run this test on debug builds because of the PR_NOT_REACHED
|
||||
// Cannot run this test on debug builds because of the NotReached
|
||||
#ifndef DEBUG
|
||||
TEST_F(pkixder_input_tests, MarkAndGetInputDifferentInput)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user