[PATCH] Add cast to unsigned char to strverscmp
Jeremy Bettis <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CAD22NBkDvgVjq2D8B4pKJQzwtp5f+1WV1nv6WyG_zajkwP7-cQ@mail.gmail.com> |
GCC 14.2 with -Werror=sign-compare fails on this code. Signed-off-by: Jeremy Bettis <[email protected]> --- newlib/libc/string/strverscmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/newlib/libc/string/strverscmp.c b/newlib/libc/string/strverscmp.c index 55966335f..e86718faa 100644 --- a/newlib/libc/string/strverscmp.c +++ b/newlib/libc/string/strverscmp.c @@ -76,7 +76,7 @@ int strverscmp(const char *l0, const char *r0) else if (c!='0') z=0; } - if (l[dp]<'1' + 9U && r[dp]<'1' + 9U) { + if ((unsigned char)(l[dp]-'1')<9U && (unsigned char)(r[dp]-'1')<9U) { /* If we're looking at non-degenerate digit sequences starting * with nonzero digits, longest digit string is greater. */ for (j=i; isdigit(l[j]); j++) -- 2.47.0.199.ga7371fff76-goog -- Jeremy Bettis | ChromeOS FAFT lead | [email protected] | 303-257-2486
smime.p7s
(application/pkcs7-signature, 5.2 KB) - not displayed