]> granicus.if.org Git - curl/commitdiff
examples/sslbackend: fix -Wchar-subscripts warning
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Fri, 18 Oct 2019 06:19:47 +0000 (08:19 +0200)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Fri, 18 Oct 2019 11:04:49 +0000 (13:04 +0200)
With the `isdigit` implementation that comes with MSYS2, the argument
is used as an array subscript, resulting in a -Wchar-subscripts
warning. `isdigit`'s behavior is undefined if the argument is negative
and not EOF [0]. As done in lib/curl_ctype.h, cast the `char` variable
to `unsigned char` to avoid that.

[0] https://en.cppreference.com/w/c/string/byte/isdigit

Closes https://github.com/curl/curl/pull/4503

docs/examples/sslbackend.c

index c1489a9aa999d34d1ede30f0f3f1f44a06ac0701..bbfa81738bd02e8e0fbe7a2a7938ecbdbbb2226d 100644 (file)
@@ -56,7 +56,7 @@ int main(int argc, char **argv)
 
     return 0;
   }
-  else if(isdigit(*name)) {
+  else if(isdigit((int)(unsigned char)*name)) {
     int id = atoi(name);
 
     result = curl_global_sslset((curl_sslbackend)id, NULL, NULL);