From c270423de16f54af26147280c406b8b74ab07046 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Wed, 9 Aug 2017 13:32:04 -0400 Subject: use unsigned to avoid runtime overflow detection Bug: skia: Change-Id: I487930955f75048ea27a1bcc61f7e0849c63759b Reviewed-on: https://skia-review.googlesource.com/32681 Commit-Queue: Mike Reed Commit-Queue: Mike Klein Reviewed-by: Mike Klein --- bench/MathBench.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bench/MathBench.cpp') diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp index 1ae683aab8..3b0fd099ab 100644 --- a/bench/MathBench.cpp +++ b/bench/MathBench.cpp @@ -630,12 +630,13 @@ public: // These exist to try to stop the compiler from detecting what we doing, and throwing // parts away (or knowing exactly how big the loop counts are). - virtual void process(int) {} + virtual void process(unsigned) {} virtual int count() { return ARRAY; } protected: void onDraw(int loops, SkCanvas*) override { - int accum = 0; + // used unsigned to avoid undefined behavior if/when the += might overflow + unsigned accum = 0; for (int j = 0; j < loops; ++j) { int n = this->count(); -- cgit v1.2.3