mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1034634: Improve ScopedNSSTypes.h to compile without warnings, r=mmc
--HG-- extra : rebase_source : a9cbc1ab3083f1e893552c49a4518453f3b7d1b7
This commit is contained in:
parent
d4e1dc58f6
commit
3637060bbc
@ -7,6 +7,8 @@
|
||||
#ifndef mozilla_ScopedNSSTypes_h
|
||||
#define mozilla_ScopedNSSTypes_h
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "NSSErrorsService.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/mozalloc_oom.h"
|
||||
@ -60,6 +62,14 @@ MapSECStatus(SECStatus rv)
|
||||
return mozilla::psm::GetXPCOMFromNSSError(PR_GetError());
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// C4061: enumerator 'symbol' in switch of enum 'symbol' is not explicitly
|
||||
// handled.
|
||||
#define MOZ_NON_EXHAUSTIVE_SWITCH __pragma(warning(suppress:4061)) switch
|
||||
#else
|
||||
#define MOZ_NON_EXHAUSTIVE_SWITCH switch
|
||||
#endif
|
||||
|
||||
// Alphabetical order by NSS type
|
||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc,
|
||||
PRFileDesc,
|
||||
@ -164,9 +174,13 @@ public:
|
||||
|
||||
nsresult DigestBuf(SECOidTag hashAlg, const uint8_t * buf, uint32_t len)
|
||||
{
|
||||
if (len > static_cast<uint32_t>(std::numeric_limits<int32_t>::max())) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
nsresult rv = SetLength(hashAlg);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return MapSECStatus(PK11_HashBuf(hashAlg, item.data, buf, len));
|
||||
return MapSECStatus(PK11_HashBuf(hashAlg, item.data, buf,
|
||||
static_cast<int32_t>(len)));
|
||||
}
|
||||
|
||||
nsresult End(SECOidTag hashAlg, ScopedPK11Context & context)
|
||||
@ -186,7 +200,7 @@ public:
|
||||
private:
|
||||
nsresult SetLength(SECOidTag hashType)
|
||||
{
|
||||
switch (hashType)
|
||||
MOZ_NON_EXHAUSTIVE_SWITCH (hashType)
|
||||
{
|
||||
case SEC_OID_SHA1: item.len = SHA1_LENGTH; break;
|
||||
case SEC_OID_SHA256: item.len = SHA256_LENGTH; break;
|
||||
|
Loading…
Reference in New Issue
Block a user