ruby-changes:56491
From: Yusuke <ko1@a...>
Date: Sun, 14 Jul 2019 21:58:37 +0900 (JST)
Subject: [ruby-changes:56491] Yusuke Endoh: 085d0e5ccb (master): ruby.c (name_match_p): remove unnecessary condition
https://git.ruby-lang.org/ruby.git/commit/?id=085d0e5ccb From 085d0e5ccb7cecb1f761c1d3c72caeeedafc7d04 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sun, 14 Jul 2019 21:56:39 +0900 Subject: ruby.c (name_match_p): remove unnecessary condition It always returns immediately when len was decremented to zero. So len is always positive. This change will suppress Coverity Scan warning. diff --git a/ruby.c b/ruby.c index c32055a..2610cf2 100644 --- a/ruby.c +++ b/ruby.c @@ -834,7 +834,7 @@ static int https://github.com/ruby/ruby/blob/trunk/ruby.c#L834 name_match_p(const char *name, const char *str, size_t len) { if (len == 0) return 0; - do { + while (1) { while (TOLOWER(*str) == *name) { if (!--len || !*++str) return 1; ++name; @@ -844,8 +844,7 @@ name_match_p(const char *name, const char *str, size_t len) https://github.com/ruby/ruby/blob/trunk/ruby.c#L844 if (*name != '-' && *name != '_') return 0; ++name; ++str; - } while (len > 0); - return !*name; + } } #define NAME_MATCH_P(name, str, len) \ -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/