Commit fd58d22c by Jamie Madill Committed by Commit Bot

Enable "-Wtautological-type-limit-compare".

This is used by Skia. It seems like a good this to enable in any case. It verifies that we don't do pointless comparisons like "int < INTMAX". Fix the one instance by using the base checked numeric helpers. Bug: angleproject:4046 Change-Id: Ie14a9cb2754df52929591281062d92ef70df8f97 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1877474Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 3db80f93
...@@ -140,6 +140,7 @@ config("extra_warnings") { ...@@ -140,6 +140,7 @@ config("extra_warnings") {
"-Wextra-semi-stmt", "-Wextra-semi-stmt",
"-Wfloat-conversion", "-Wfloat-conversion",
"-Wnon-virtual-dtor", "-Wnon-virtual-dtor",
"-Wtautological-type-limit-compare",
"-Wunneeded-internal-declaration", "-Wunneeded-internal-declaration",
# The below warnings are used by WebKit. We enable them to make rolling # The below warnings are used by WebKit. We enable them to make rolling
......
...@@ -883,7 +883,7 @@ unsigned int ParseArrayIndex(const std::string &name, size_t *nameLengthWithoutA ...@@ -883,7 +883,7 @@ unsigned int ParseArrayIndex(const std::string &name, size_t *nameLengthWithoutA
strtoul(name.c_str() + open + 1, /*endptr*/ nullptr, /*radix*/ 10); strtoul(name.c_str() + open + 1, /*endptr*/ nullptr, /*radix*/ 10);
// Check if resulting integer is out-of-range or conversion error. // Check if resulting integer is out-of-range or conversion error.
if ((subscript <= static_cast<unsigned long>(UINT_MAX)) && if (angle::base::IsValueInRangeForNumericType<uint32_t>(subscript) &&
!(subscript == ULONG_MAX && errno == ERANGE) && !(errno != 0 && subscript == 0)) !(subscript == ULONG_MAX && errno == ERANGE) && !(errno != 0 && subscript == 0))
{ {
*nameLengthWithoutArrayIndexOut = open; *nameLengthWithoutArrayIndexOut = open;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment