Closed Bug 1089478 Opened 10 years ago Closed 10 years ago

Clang 3.5 -Wabsolute-value warnings in WebRTC code (mostly abs vs. std::abs)

Categories

(Core :: WebRTC, defect)

x86_64
FreeBSD
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: jbeich, Assigned: jbeich)

References

Details

Attachments

(1 file, 1 obsolete file)

$ ./mach warnings-list | fgrep absolute-value
media/webrtc/trunk/webrtc/modules/audio_processing/aec/aec_core.c:739:24 [-Wabsolute-value] using floating point absolute value function 'fabs' when argument is of integer type
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:252:38 [-Wabsolute-value] absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:255:7 [-Wabsolute-value] absolute value function 'fabsf' given an argument of type 'const double' but has parameter of type 'float' which may cause truncation of value
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:361:7 [-Wabsolute-value] absolute value function 'fabsf' given an argument of type 'const double' but has parameter of type 'float' which may cause truncation of value
media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_estimator.cc:165:9 [-Wabsolute-value] using integer absolute value function 'abs' when argument is of floating point type
media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_estimator.cc:260:34 [-Wabsolute-value] using integer absolute value function 'abs' when argument is of floating point type
media/webrtc/trunk/webrtc/modules/video_coding/main/source/receiver.cc:162:14 [-Wabsolute-value] absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value
media/webrtc/trunk/webrtc/modules/video_coding/main/source/receiver.cc:167:35 [-Wabsolute-value] absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value
media/webrtc/trunk/webrtc/modules/video_coding/main/source/rtt_filter.cc:117:9 [-Wabsolute-value] using integer absolute value function 'abs' when argument is of floating point type

or more verbose

media/webrtc/trunk/webrtc/modules/audio_processing/aec/aec_core.c:739:24: warning:
      using floating point absolute value function 'fabs' when argument is of
      integer type [-Wabsolute-value]
    l1_norm += (float)(fabs(i - my_median) * self->delay_histogram[i]);
                       ^
media/webrtc/trunk/webrtc/modules/audio_processing/aec/aec_core.c:739:24: note:
      use function 'abs' instead
    l1_norm += (float)(fabs(i - my_median) * self->delay_histogram[i]);
                       ^~~~
                       abs
1 warning generated.

In file included from media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_components_rbe_components/Unified_cpp_nents_rbe_components0.cpp:2:
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:252:38: warning:
      absolute value function 'fabsf' given an argument of type 'double' but has
      parameter of type 'float' which may cause truncation of value
      [-Wabsolute-value]
      (BWE_MIN(num_of_deltas_, 60) * fabsf(offset_) < threshold_);
                                     ^
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:252:38: note:
      use function 'std::abs' instead
      (BWE_MIN(num_of_deltas_, 60) * fabsf(offset_) < threshold_);
                                     ^~~~~
                                     std::abs
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:252:38: note:
      include the header <cmath> or explicitly provide a declaration for 'std::abs'
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:255:7: warning:
      absolute value function 'fabsf' given an argument of type 'const double' but
      has parameter of type 'float' which may cause truncation of value
      [-Wabsolute-value]
  if (fabsf(residual) < 3 * sqrt(var_noise_)) {
      ^
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:255:7: note:
      use function 'std::abs' instead
  if (fabsf(residual) < 3 * sqrt(var_noise_)) {
      ^~~~~
      std::abs
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:255:7: note:
      include the header <cmath> or explicitly provide a declaration for 'std::abs'
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:361:7: warning:
      absolute value function 'fabsf' given an argument of type 'const double' but
      has parameter of type 'float' which may cause truncation of value
      [-Wabsolute-value]
  if (fabsf(T) > threshold_) {
      ^
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:361:7: note:
      use function 'std::abs' instead
  if (fabsf(T) > threshold_) {
      ^~~~~
      std::abs
media/webrtc/trunk/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc:361:7: note:
      include the header <cmath> or explicitly provide a declaration for 'std::abs'
3 warnings generated.

In file included from media/webrtc/trunk/webrtc/modules/modules_webrtc_video_coding/Unified_cpp__webrtc_video_coding0.cpp:92:
media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_estimator.cc:165:9: warning:
      using integer absolute value function 'abs' when argument is of floating point
      type [-Wabsolute-value]
    if (abs(deviation) < _numStdDevDelayOutlier * sqrt(_varNoise) ||
        ^
media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_estimator.cc:165:9: note:
      use function 'std::abs' instead
    if (abs(deviation) < _numStdDevDelayOutlier * sqrt(_varNoise) ||
        ^~~
        std::abs
media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_estimator.cc:165:9: note:
      include the header <cmath> or explicitly provide a declaration for 'std::abs'
media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_estimator.cc:260:34: warning:
      using integer absolute value function 'abs' when argument is of floating point
      type [-Wabsolute-value]
    double sigma = (300.0 * exp(-abs(static_cast<double>(deltaFSBytes)) /
                                 ^
media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_estimator.cc:260:34: note:
      use function 'std::abs' instead
    double sigma = (300.0 * exp(-abs(static_cast<double>(deltaFSBytes)) /
                                 ^~~
                                 std::abs
media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_estimator.cc:260:34: note:
      include the header <cmath> or explicitly provide a declaration for 'std::abs'
In file included from media/webrtc/trunk/webrtc/modules/modules_webrtc_video_coding/Unified_cpp__webrtc_video_coding0.cpp:137:
media/webrtc/trunk/webrtc/modules/video_coding/main/source/receiver.cc:162:14: warning:
      absolute value function 'abs' given an argument of type 'long' but has
      parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
  } else if (abs(next_render_time_ms - now_ms) > max_video_delay_ms_) {
             ^
media/webrtc/trunk/webrtc/modules/video_coding/main/source/receiver.cc:162:14: note:
      use function 'std::abs' instead
  } else if (abs(next_render_time_ms - now_ms) > max_video_delay_ms_) {
             ^~~
             std::abs
media/webrtc/trunk/webrtc/modules/video_coding/main/source/receiver.cc:167:35: warning:
      absolute value function 'abs' given an argument of type 'long' but has
      parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
                 static_cast<int>(abs(next_render_time_ms - now_ms)),
                                  ^
media/webrtc/trunk/webrtc/modules/video_coding/main/source/receiver.cc:167:35: note:
      use function 'std::abs' instead
                 static_cast<int>(abs(next_render_time_ms - now_ms)),
                                  ^~~
                                  std::abs
4 warnings generated.

In file included from media/webrtc/trunk/webrtc/modules/modules_webrtc_video_coding/Unified_cpp__webrtc_video_coding1.cpp:2:
media/webrtc/trunk/webrtc/modules/video_coding/main/source/rtt_filter.cc:117:9: warning:
      using integer absolute value function 'abs' when argument is of floating point
      type [-Wabsolute-value]
    if (abs(diffFromAvg) > _jumpStdDevs * sqrt(_varRtt))
        ^
media/webrtc/trunk/webrtc/modules/video_coding/main/source/rtt_filter.cc:117:9: note:
      use function 'std::abs' instead
    if (abs(diffFromAvg) > _jumpStdDevs * sqrt(_varRtt))
        ^~~
        std::abs
media/webrtc/trunk/webrtc/modules/video_coding/main/source/rtt_filter.cc:117:9: note:
      include the header <cmath> or explicitly provide a declaration for 'std::abs'
1 warning generated.
Comment on attachment 8511815 [details] [diff] [review]
fix

Review of attachment 8511815 [details] [diff] [review]:
-----------------------------------------------------------------

I note there's a fix for a "can't be null" test as well in digital_agc.c; I'd prefer to not change the meaning of that upstream routine (right now the only caller ensures stt isn't null, but they are careful to handle null and just return an error (-1), so let's maintain that behavior and change the test to "if (stt == NULL) { return -1; }"  That will avoid surprises if there are changes upstream we import.
Attachment #8511815 - Flags: review?(rjesup) → review+
Attached patch fix, v1.1Splinter Review
r? again in case of typos

https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=fec4acccce84
Attachment #8511815 - Attachment is obsolete: true
Attachment #8512005 - Flags: review?(rjesup)
Attachment #8512005 - Flags: review?(rjesup) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/2a1404167fb6
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
Depends on: 1122547
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: