From a2479b1a9f01ec11a43236ee4eea93ac0c16f724 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 9 Dec 2021 13:48:30 +0100 Subject: [PATCH] plugins: Force types for isalnum and isblank MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- plugins/memblaze/memblaze-nvme.c | 2 +- plugins/micron/micron-nvme.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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]; } -- 2.50.1