aboutsummaryrefslogtreecommitdiff
path: root/unit_test/unit_test.cc
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2016-02-02 14:32:12 -0800
committerFrank Barchard <fbarchard@google.com>2016-02-02 14:32:12 -0800
commit903c91cc2e3c831748d6f6168b7a8bb98f6ab9ec (patch)
tree5ae84df152aa18f3ddfaa08cc95d42602bb79213 /unit_test/unit_test.cc
parent05ed0c539c3912c9e284d6fceb209dfc6077df25 (diff)
downloadlibyuv-903c91cc2e3c831748d6f6168b7a8bb98f6ab9ec.tar.gz
fix for ubsan on unittest.h fastrand()
internal math of the fastrand function uses a multiply and add that overflows a signed int. This triggers a ubsan failure: ../../unit_test/../unit_test/unit_test.h:60:33: runtime error: signed integer overflow: 56248274 * 214013 cannot be represented in type 'int' This change casts the intermediate math to unsigned int to avoid the overflow. For more info on ubsan, see http://dev.chromium.org/developers/testing/undefinedbehaviorsanitizer TESTED=Passing compilation using: GYP_DEFINES="ubsan=1" GYP_DEFINES="ubsan_vptr=1" R=harryjin@google.com, pbos@webrtc.org BUG=libyuv:563 Review URL: https://codereview.chromium.org/1662453003 .
Diffstat (limited to 'unit_test/unit_test.cc')
-rw-r--r--unit_test/unit_test.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/unit_test/unit_test.cc b/unit_test/unit_test.cc
index c3fec6b3..c98c285c 100644
--- a/unit_test/unit_test.cc
+++ b/unit_test/unit_test.cc
@@ -20,7 +20,7 @@
// TODO(fbarchard): Add command line parsing to pass this as option.
#define BENCHMARK_ITERATIONS 1
-int fastrand_seed = 0xfb;
+unsigned int fastrand_seed = 0xfb;
DEFINE_int32(libyuv_width, 0, "width of test image.");
DEFINE_int32(libyuv_height, 0, "height of test image.");
@@ -125,7 +125,7 @@ LibYUVColorTest::LibYUVColorTest() :
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
- benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
+ benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
@@ -177,7 +177,7 @@ LibYUVScaleTest::LibYUVScaleTest() :
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
- benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
+ benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
@@ -229,7 +229,7 @@ LibYUVRotateTest::LibYUVRotateTest() :
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
- benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
+ benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
@@ -281,7 +281,7 @@ LibYUVPlanarTest::LibYUVPlanarTest() :
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
- benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
+ benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *
@@ -333,7 +333,7 @@ LibYUVBaseTest::LibYUVBaseTest() :
benchmark_cpu_info_ = atoi(cpu_flags); // NOLINT
}
if (FLAGS_libyuv_cpu_info) {
- benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
+ benchmark_cpu_info_ = FLAGS_libyuv_cpu_info;
}
benchmark_pixels_div256_ = static_cast<int>((
static_cast<double>(Abs(benchmark_width_)) *