Fix: relayd: cast idigit argument to unsigned char
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 25 Mar 2020 22:39:48 +0000 (18:39 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 26 Mar 2020 22:01:40 +0000 (18:01 -0400)
This diagnostic is emitted when building on cygwin:

    main.c:233:34: warning: array subscript has type ‘char’ [-Wchar-subscripts]
      233 |    if (errno != 0 || !isdigit(arg[0])) {
          |                               ~~~^~~

This is due to passing a `char` argument to isdigit.  According to the
man page of isdigit, the arguments of type `char` must be cast to
`unsigned char`, so they are able to represent the EOF value.  This
patch does that, and should get rid of the warning.

Change-Id: Iaed4c0b494a79b917761e65f18388f43478b97e1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/main.c

index 7f7c0369a1bbf935b3ce66b46d36cf94bfeaa9b6..12b7b74f6d8ad7cc5d43799396ee4ba27d456bc2 100644 (file)
@@ -230,7 +230,7 @@ static int set_option(int opt, const char *arg, const char *optname)
 
                        errno = 0;
                        v = strtoul(arg, NULL, 0);
-                       if (errno != 0 || !isdigit(arg[0])) {
+                       if (errno != 0 || !isdigit((unsigned char) arg[0])) {
                                ERR("Wrong value in --fd-pool-size parameter: %s", arg);
                                ret = -1;
                                goto end;
This page took 0.02652 seconds and 4 git commands to generate.