Bug 1575924 - A couple more clang-tidy checks for Resist Fingerprinting r=timhuang
authorTom Ritter <tom@mozilla.com>
Fri, 23 Aug 2019 07:33:48 +0000
changeset 489584 79f74b10e771b8a1cdb8a12ee25e962423a52829
parent 489583 bcf1874cde5435ef9ca8503b3319c3ead7740f5a
child 489585 a7a5fdf0f2cb673f06d71a801cdaba9209943069
push id36478
push userdvarga@mozilla.com
push dateFri, 23 Aug 2019 21:49:00 +0000
treeherdermozilla-central@9f96b6821f1d [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 - A couple more clang-tidy checks for Resist Fingerprinting r=timhuang Depends on D43107 Differential Revision: https://phabricator.services.mozilla.com/D43108
toolkit/components/resistfingerprinting/nsRFPService.cpp
--- a/toolkit/components/resistfingerprinting/nsRFPService.cpp
+++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp
@@ -529,17 +529,18 @@ double nsRFPService::ReduceTimePrecision
   // that comparing two clamped values that should be related by a constant
   // (e.g. 10s) that are across the zero barrier will no longer work. We need to
   // round consistently towards positive infinity or negative infinity (we chose
   // negative.) This can't be done with a truncation, it must be done with
   // floor.
   long long clamped =
       floor(double(timeAsInt) / resolutionAsInt) * resolutionAsInt;
 
-  long long midpoint = 0, clampedAndJittered = clamped;
+  long long midpoint = 0;
+  long long clampedAndJittered = clamped;
   if (!unconditionalClamping &&
       StaticPrefs::privacy_resistFingerprinting_reduceTimerPrecision_jitter()) {
     if (!NS_FAILED(RandomMidpoint(clamped, resolutionAsInt, aContextMixin,
                                   &midpoint)) &&
         timeAsInt >= clamped + midpoint) {
       clampedAndJittered += resolutionAsInt;
     }
   }
@@ -620,17 +621,17 @@ uint32_t nsRFPService::GetSpoofedDropped
   // report a zero dropped rate for this case.
   if (targetRes >= aWidth * aHeight) {
     return 0;
   }
 
   double precision = TimerResolution() / 1000 / 1000;
   double time = floor(aTime / precision) * precision;
   // Bound the dropped ratio from 0 to 100.
-  uint32_t boundedDroppedRatio = min(kVideoDroppedRatio, 100u);
+  uint32_t boundedDroppedRatio = min(kVideoDroppedRatio, 100U);
 
   return NSToIntFloor(time * kVideoFramesPerSec *
                       (boundedDroppedRatio / 100.0));
 }
 
 /* static */
 uint32_t nsRFPService::GetSpoofedPresentedFrames(double aTime, uint32_t aWidth,
                                                  uint32_t aHeight) {
@@ -641,17 +642,17 @@ uint32_t nsRFPService::GetSpoofedPresent
   // case, there will be no dropped frames, so we report total frames directly.
   if (targetRes >= aWidth * aHeight) {
     return GetSpoofedTotalFrames(aTime);
   }
 
   double precision = TimerResolution() / 1000 / 1000;
   double time = floor(aTime / precision) * precision;
   // Bound the dropped ratio from 0 to 100.
-  uint32_t boundedDroppedRatio = min(kVideoDroppedRatio, 100u);
+  uint32_t boundedDroppedRatio = min(kVideoDroppedRatio, 100U);
 
   return NSToIntFloor(time * kVideoFramesPerSec *
                       ((100 - boundedDroppedRatio) / 100.0));
 }
 
 static uint32_t GetSpoofedVersion() {
   // If we can't get the current Firefox version, use a hard-coded ESR version.
   const uint32_t kKnownEsrVersion = 60;