Skip to content

Commit

Permalink
gpio: fix armclang compiler warnings with is*() functions
Browse files Browse the repository at this point in the history
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <[email protected]>
  • Loading branch information
galak authored and cfriedt committed Apr 1, 2023
1 parent 28bb21c commit d82175e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/gpio/gpio_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ static int cmd_gpio_conf(const struct shell *sh, size_t argc, char **argv)
int type = GPIO_OUTPUT;
const struct device *dev;

if (isdigit((unsigned char)argv[args_indx.index][0]) &&
isalpha((unsigned char)argv[args_indx.mode][0])) {
if (isdigit((unsigned char)argv[args_indx.index][0]) != 0 &&
isalpha((unsigned char)argv[args_indx.mode][0]) != 0) {
index = (uint8_t)atoi(argv[args_indx.index]);
if (!strcmp(argv[args_indx.mode], "in")) {
type = GPIO_INPUT;
Expand Down Expand Up @@ -79,7 +79,7 @@ static int cmd_gpio_get(const struct shell *sh,
uint8_t index = 0U;
int rc;

if (isdigit((unsigned char)argv[args_indx.index][0])) {
if (isdigit((unsigned char)argv[args_indx.index][0]) != 0) {
index = (uint8_t)atoi(argv[args_indx.index]);
} else {
shell_error(sh, "Wrong parameters for get");
Expand Down Expand Up @@ -111,8 +111,8 @@ static int cmd_gpio_set(const struct shell *sh,
uint8_t index = 0U;
uint8_t value = 0U;

if (isdigit((unsigned char)argv[args_indx.index][0]) &&
isdigit((unsigned char)argv[args_indx.value][0])) {
if (isdigit((unsigned char)argv[args_indx.index][0]) != 0 &&
isdigit((unsigned char)argv[args_indx.value][0]) != 0) {
index = (uint8_t)atoi(argv[args_indx.index]);
value = (uint8_t)atoi(argv[args_indx.value]);
} else {
Expand Down Expand Up @@ -144,7 +144,7 @@ static int cmd_gpio_blink(const struct shell *sh,
size_t count = 0;
char data;

if (isdigit((unsigned char)argv[args_indx.index][0])) {
if (isdigit((unsigned char)argv[args_indx.index][0]) != 0) {
index = (uint8_t)atoi(argv[args_indx.index]);
} else {
shell_error(sh, "Wrong parameters for blink");
Expand Down

0 comments on commit d82175e

Please sign in to comment.