Bug 1694604 - Fix static analysis warnings in netwerk/dns r=necko-reviewers,dragana

Depends on D106262

Differential Revision: https://phabricator.services.mozilla.com/D106263
This commit is contained in:
Valentin Gosu 2021-02-24 16:37:04 +00:00
Родитель ff32c214b6
Коммит 86622ba6a3
7 изменённых файлов: 39 добавлений и 41 удалений

Просмотреть файл

@ -159,15 +159,15 @@ static const char kODoHKey[] = "odoh key";
static const char kODoHNonce[] = "odoh nonce";
struct ObliviousDoHConfigContents {
uint16_t mKemId;
uint16_t mKdfId;
uint16_t mAeadId;
uint16_t mKemId{};
uint16_t mKdfId{};
uint16_t mAeadId{};
nsTArray<uint8_t> mPublicKey;
};
struct ObliviousDoHConfig {
uint16_t mVersion;
uint16_t mLength;
uint16_t mVersion{};
uint16_t mLength{};
ObliviousDoHConfigContents mContents;
nsTArray<uint8_t> mConfigId;
};

Просмотреть файл

@ -1031,7 +1031,7 @@ static bool CreateConfigId(ObliviousDoHConfig& aConfig) {
UniquePK11SymKey configKey(PK11_ImportDataKey(slot.get(), CKM_HKDF_DATA,
PK11_OriginUnwrap, CKA_DERIVE,
rawConfig.get(), NULL));
rawConfig.get(), nullptr));
if (!configKey) {
return false;
}
@ -1382,7 +1382,7 @@ static SECStatus HKDFExtract(SECItem* aSalt, PK11SymKey* aIkm,
params.bExpand = CK_FALSE;
params.prfHashMechanism = CKM_SHA256;
params.ulSaltType = aSalt ? CKF_HKDF_SALT_DATA : CKF_HKDF_SALT_NULL;
params.pSalt = aSalt ? (CK_BYTE_PTR)aSalt->data : NULL;
params.pSalt = aSalt ? (CK_BYTE_PTR)aSalt->data : nullptr;
params.ulSaltLen = aSalt ? aSalt->len : 0;
UniquePK11SymKey prk(PK11_Derive(aIkm, CKM_HKDF_DERIVE, &paramsItem,

Просмотреть файл

@ -31,8 +31,7 @@
#include "mozilla/Logging.h"
#include "mozilla/StaticPrefs_network.h"
namespace mozilla {
namespace net {
namespace mozilla::net {
static StaticRefPtr<NativeDNSResolverOverride> gOverrideService;
@ -462,5 +461,4 @@ NS_IMETHODIMP NativeDNSResolverOverride::ClearOverrides() {
return NS_OK;
}
} // namespace net
} // namespace mozilla
} // namespace mozilla::net

Просмотреть файл

@ -14,7 +14,7 @@ namespace net {
// A blocklist range is defined as all of the characters between:
// { firstCharacterInRange, lastCharacterInRange }
typedef std::pair<char16_t, char16_t> BlocklistRange;
using BlocklistRange = std::pair<char16_t, char16_t>;
// Used to perform a binary search of the needle in the sorted array of pairs
class BlocklistPairToCharComparator {

Просмотреть файл

@ -221,34 +221,34 @@ AHostResolver::LookupStatus TRRQuery::CompleteLookup(
LOG(("CompleteLookup: waiting for all responses!\n"));
return LOOKUP_OK;
} else {
// no more outstanding TRRs
// If mFirstTRR is set, merge those addresses into current set!
if (mFirstTRR) {
if (NS_SUCCEEDED(status)) {
LOG(("Merging responses"));
newRRSet = merge_rrset(newRRSet, mFirstTRR);
} else {
LOG(("Will use previous response"));
newRRSet.swap(mFirstTRR); // transfers
// We must use the status of the first response, otherwise we'll
// pass an error result to the consumers.
status = mFirstTRRresult;
}
mFirstTRR = nullptr;
} else {
if (NS_FAILED(status) && status != NS_ERROR_DEFINITIVE_UNKNOWN_HOST &&
mFirstTRRresult == NS_ERROR_DEFINITIVE_UNKNOWN_HOST) {
status = NS_ERROR_DEFINITIVE_UNKNOWN_HOST;
}
}
}
if (mTRRSuccess && mHostResolver->GetNCS() &&
(mHostResolver->GetNCS()->GetNAT64() ==
nsINetworkConnectivityService::OK) &&
newRRSet) {
newRRSet = mHostResolver->GetNCS()->MapNAT64IPs(newRRSet);
// no more outstanding TRRs
// If mFirstTRR is set, merge those addresses into current set!
if (mFirstTRR) {
if (NS_SUCCEEDED(status)) {
LOG(("Merging responses"));
newRRSet = merge_rrset(newRRSet, mFirstTRR);
} else {
LOG(("Will use previous response"));
newRRSet.swap(mFirstTRR); // transfers
// We must use the status of the first response, otherwise we'll
// pass an error result to the consumers.
status = mFirstTRRresult;
}
mFirstTRR = nullptr;
} else {
if (NS_FAILED(status) && status != NS_ERROR_DEFINITIVE_UNKNOWN_HOST &&
mFirstTRRresult == NS_ERROR_DEFINITIVE_UNKNOWN_HOST) {
status = NS_ERROR_DEFINITIVE_UNKNOWN_HOST;
}
}
if (mTRRSuccess && mHostResolver->GetNCS() &&
(mHostResolver->GetNCS()->GetNAT64() ==
nsINetworkConnectivityService::OK) &&
newRRSet) {
newRRSet = mHostResolver->GetNCS()->MapNAT64IPs(newRRSet);
}
if (resolverType == DNSResolverType::TRR) {

Просмотреть файл

@ -162,7 +162,7 @@ nsDNSServiceInfo::GetAttributes(nsIPropertyBag2** aAttributes) {
NS_IMETHODIMP
nsDNSServiceInfo::SetAttributes(nsIPropertyBag2* aAttributes) {
mAttributes = aAttributes;
mIsAttributesSet = aAttributes ? true : false;
mIsAttributesSet = aAttributes != nullptr;
return NS_OK;
}

Просмотреть файл

@ -77,7 +77,7 @@ struct nsHostKey {
class nsHostRecord : public mozilla::LinkedListElement<RefPtr<nsHostRecord>>,
public nsHostKey,
public nsISupports {
typedef mozilla::net::TRRSkippedReason TRRSkippedReason;
using TRRSkippedReason = mozilla::net::TRRSkippedReason;
public:
NS_DECL_THREADSAFE_ISUPPORTS
@ -185,7 +185,7 @@ class nsHostRecord : public mozilla::LinkedListElement<RefPtr<nsHostRecord>>,
}
class AddrHostRecord final : public nsHostRecord {
typedef mozilla::Mutex Mutex;
using Mutex = mozilla::Mutex;
public:
NS_DECLARE_STATIC_IID_ACCESSOR(ADDRHOSTRECORD_IID)