From 28659883618d3c015defe91de504af96bc98afdb Mon Sep 17 00:00:00 2001 From: "epoger@google.com" Date: Mon, 16 Jul 2012 18:01:06 +0000 Subject: [PATCH] skdiff: cap return value at 255 to avoid automatic 'wrapping' (%256) of return value Review URL: https://codereview.appspot.com/6409045 git-svn-id: http://skia.googlecode.com/svn/trunk@4629 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tools/skdiff_main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp index f20475aed..eea0e0d04 100644 --- a/tools/skdiff_main.cpp +++ b/tools/skdiff_main.cpp @@ -1307,5 +1307,9 @@ int main (int argc, char ** argv) { Result type = failOnTheseResultTypes[i]; num_failing_results += summary.fResultsOfType[type].count(); } - return num_failing_results; + + // On Linux (and maybe other platforms too), any results outside of the + // range [0...255] are wrapped (mod 256). Do the conversion ourselves, to + // make sure that we only return 0 when there were no failures. + return (num_failing_results > 255) ? 255 : num_failing_results; }