From: Daniel Wagner Date: Thu, 9 Dec 2021 12:48:30 +0000 (+0100) Subject: plugins: Force types for isalnum and isblank X-Git-Tag: v2.0-rc0~31^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a2479b1a9f01ec11a43236ee4eea93ac0c16f724;p=users%2Fsagi%2Fnvme-cli.git plugins: Force types for isalnum and isblank 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 --- diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c index 5c0b22bb..85ed642a 100644 --- a/plugins/memblaze/memblaze-nvme.c +++ b/plugins/memblaze/memblaze-nvme.c @@ -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; } diff --git a/plugins/micron/micron-nvme.c b/plugins/micron/micron-nvme.c index 9eef88e6..3ac90158 100644 --- a/plugins/micron/micron-nvme.c +++ b/plugins/micron/micron-nvme.c @@ -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]; }