]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugins: Force types for isalnum and isblank
authorDaniel Wagner <dwagner@suse.de>
Thu, 9 Dec 2021 12:48:30 +0000 (13:48 +0100)
committerDaniel Wagner <dwagner@suse.de>
Thu, 9 Dec 2021 12:55:02 +0000 (13:55 +0100)
The two users of isalnum and isblank hand in unsigned char and not
int as expected by the API. This triggers thye type checker in the
debug build, e.g.

../subprojects/libnvme/ccan/ccan/build_assert/build_assert.h:38:22: error: size of unnamed array is negative
   38 |         (sizeof(char [1 - 2*!(cond)]) - 1)
      |                      ^
../ccan/ccan/str/str.h:189:16: note: in expansion of macro ‘BUILD_ASSERT_OR_ZERO’
  189 |         ((i) + BUILD_ASSERT_OR_ZERO(!__builtin_types_compatible_p(typeof(i), \
      |                ^~~~~~~~~~~~~~~~~~~~
../ccan/ccan/str/str.h:196:32: note: in expansion of macro ‘str_check_arg_’
  196 | #define isalnum(i) str_isalnum(str_check_arg_(i))
      |                                ^~~~~~~~~~~~~~
../plugins/memblaze/memblaze-nvme.c:410:13: note: in expansion of macro ‘isalnum’
  410 |         if (isalnum(*c) == 0) {
      |             ^~~~~~~

Signed-off-by: Daniel Wagner <dwagner@suse.de>
plugins/memblaze/memblaze-nvme.c
plugins/micron/micron-nvme.c

index 5c0b22bb38e4fce77efe36b3da3a1f4af238ac0a..85ed642a784545c2d54c036deca4b5b169a0182f 100644 (file)
@@ -407,7 +407,7 @@ int parse_params(char *str, int number, ...)
             exit(EINVAL);
         }
 
-        if (isalnum(*c) == 0) {
+        if (isalnum((int)*c) == 0) {
             printf("%s is not a valid number\n", c);
             return 1;
         }
index 9eef88e6dd68cd1c7648a2d78c20f8c7354b056c..3ac9015865f5def98dbf3cde6fe8aff24dcb1007 100644 (file)
@@ -2513,7 +2513,7 @@ static int micron_internal_logs(int argc, char **argv, struct command *cmd,
     // trim spaces out of serial number string */
     int i, j = 0;
     for (i = 0; i < sizeof(ctrl.sn); i++) {
-        if (isblank(ctrl.sn[i]))
+        if (isblank((int)ctrl.sn[i]))
             continue;
         sn[j++] = ctrl.sn[i];
     }