From e9f9c0d81c73d8b6d87700aadb5b886bd289769a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 11 Oct 2018 21:37:45 -0400 Subject: [PATCH] [sanitize] Reorder condition to silence bogus gcc warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was givin a dozen of: ../../src/hb-machinery.hh: In member function ‘bool AAT::ankr::sanitize(hb_sanitize_context_t*) const’: ../../src/hb-machinery.hh:307:23: warning: missed loop optimization, the loop counter may overflow [-Wunsafe-loop-optimizations] bool ok = --this->max_ops > 0 && ~~~~~~~~~~~~~~~~~~~~~~ this->start <= p && ~~~~~~~~~~~~~~~~~~~ p <= this->end && ~~~~~~~~~~~~~~~^~ (unsigned int) (this->end - p) >= len; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I believe those are bogus, but this silences them and does not introduce logic issues I believe. --- src/hb-machinery.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index 56914bea..a6ff6e7b 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -302,10 +302,10 @@ struct hb_sanitize_context_t : inline bool check_range (const void *base, unsigned int len) const { const char *p = (const char *) base; - bool ok = this->max_ops-- > 0 && - this->start <= p && + bool ok = this->start <= p && p <= this->end && - (unsigned int) (this->end - p) >= len; + (unsigned int) (this->end - p) >= len && + this->max_ops-- > 0; DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, "check_range [%p..%p] (%d bytes) in [%p..%p] -> %s", -- GitLab