1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
Yusuke Endoh 2019-07-14 21:56:39 +09:00
parent a3493521a5
commit 085d0e5ccb

5
ruby.c
View file

@ -834,7 +834,7 @@ static int
name_match_p(const char *name, const char *str, size_t len) name_match_p(const char *name, const char *str, size_t len)
{ {
if (len == 0) return 0; if (len == 0) return 0;
do { while (1) {
while (TOLOWER(*str) == *name) { while (TOLOWER(*str) == *name) {
if (!--len || !*++str) return 1; if (!--len || !*++str) return 1;
++name; ++name;
@ -844,8 +844,7 @@ name_match_p(const char *name, const char *str, size_t len)
if (*name != '-' && *name != '_') return 0; if (*name != '-' && *name != '_') return 0;
++name; ++name;
++str; ++str;
} while (len > 0); }
return !*name;
} }
#define NAME_MATCH_P(name, str, len) \ #define NAME_MATCH_P(name, str, len) \