Bug 1575924 - Final clang-tidy checks for Resist Fingerprinting r=timhuang
authorTom Ritter <tom@mozilla.com>
Fri, 23 Aug 2019 07:35:32 +0000
changeset 489594 a7a5fdf0f2cb673f06d71a801cdaba9209943069
parent 489593 79f74b10e771b8a1cdb8a12ee25e962423a52829
child 489595 b3dc91a89d99b61f9d6b71fc33faaf0edd7ec4d1
push id93465
push usertritter@mozilla.com
push dateFri, 23 Aug 2019 13:13:49 +0000
treeherderautoland@a7a5fdf0f2cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimhuang
bugs1575924
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1575924 - Final clang-tidy checks for Resist Fingerprinting r=timhuang Deleting a null pointer has no effect. Else after return. Depends on D43108 Differential Revision: https://phabricator.services.mozilla.com/D43109
toolkit/components/resistfingerprinting/nsRFPService.cpp
--- a/toolkit/components/resistfingerprinting/nsRFPService.cpp
+++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp
@@ -340,19 +340,19 @@ nsresult nsRFPService::RandomMidpoint(lo
 
   nsCString hashResult = cache->Get(extraClampedTime, aContextMixin);
 
   if (hashResult.Length() != HASH_DIGEST_SIZE_BYTES) {  // Cache Miss =(
     // If someone has pased in the testing-only parameter, replace our seed with
     // it
     if (aSecretSeed != nullptr) {
       StaticMutexAutoLock lock(sLock);
-      if (sSecretMidpointSeed != nullptr) {
-        delete[] sSecretMidpointSeed;
-      }
+
+      delete[] sSecretMidpointSeed;
+
       sSecretMidpointSeed = new uint8_t[kSeedSize];
       memcpy(sSecretMidpointSeed, aSecretSeed, kSeedSize);
     }
 
     // If we don't have a seed, we need to get one.
     if (MOZ_UNLIKELY(!sSecretMidpointSeed)) {
       nsCOMPtr<nsIRandomGenerator> randomGenerator =
           do_GetService("@mozilla.org/security/random-generator;1", &rv);
@@ -469,22 +469,21 @@ double nsRFPService::ReduceTimePrecision
   // This boolean will serve as a flag indicating we are clamping the time
   // unconditionally. We do this when timer reduction preference is off; but we
   // still want to apply 20us clamping to al timestamps to avoid leaking
   // nano-second precision.
   bool unconditionalClamping = false;
   if (!IsTimerPrecisionReductionEnabled(aType)) {
     if (!StaticPrefs::privacy_reduceTimerPrecision_unconditional()) {
       return aTime;
-    } else {
-      unconditionalClamping = true;
-      aResolutionUSec = RFP_TIMER_UNCONDITIONAL_VALUE;  // 20 microseconds
-      aContextMixin = 0;  // Just clarifies our logging statement at the end,
-                          // otherwise unused
     }
+    unconditionalClamping = true;
+    aResolutionUSec = RFP_TIMER_UNCONDITIONAL_VALUE;  // 20 microseconds
+    aContextMixin = 0;  // Just clarifies our logging statement at the end,
+                        // otherwise unused
   }
 
   if (aResolutionUSec <= 0) {
     return aTime;
   }
 
   // Increase the time as needed until it is in microseconds.
   // Note that a double can hold up to 2**53 with integer precision. This gives