diff options
| author | David Lamparter <equinox@diac24.net> | 2019-08-06 16:54:52 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2019-08-06 16:54:52 +0200 |
| commit | fefa5e0ff5af98d8258987e21422243926ee2b3c (patch) | |
| tree | 05ad830d4a48048156689b15a5c84df124964cb6 /lib/command.c | |
| parent | 7040d52aafca16fb0048c1712a919d8209c54dc9 (diff) | |
*: fix ctype (isalpha & co.) casts
The correct cast for these is (unsigned char), because "char" could be
signed and thus have some negative value. isalpha & co. expect an int
arg that is positive, i.e. 0-255. So we need to cast to (unsigned char)
when calling any of these.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/command.c b/lib/command.c index c8fbf22721..ef5167863e 100644 --- a/lib/command.c +++ b/lib/command.c @@ -290,7 +290,7 @@ vector cmd_make_strvec(const char *string) const char *copy = string; /* skip leading whitespace */ - while (isspace((int)*copy) && *copy != '\0') + while (isspace((unsigned char)*copy) && *copy != '\0') copy++; /* if the entire string was whitespace or a comment, return */ @@ -1936,7 +1936,7 @@ DEFUN(config_domainname, { struct cmd_token *word = argv[1]; - if (!isalpha((int)word->arg[0])) { + if (!isalpha((unsigned char)word->arg[0])) { vty_out(vty, "Please specify string starting with alphabet\n"); return CMD_WARNING_CONFIG_FAILED; } @@ -1970,7 +1970,7 @@ DEFUN (config_hostname, { struct cmd_token *word = argv[1]; - if (!isalnum((int)word->arg[0])) { + if (!isalnum((unsigned char)word->arg[0])) { vty_out(vty, "Please specify string starting with alphabet or number\n"); return CMD_WARNING_CONFIG_FAILED; @@ -2018,7 +2018,7 @@ DEFUN (config_password, return CMD_SUCCESS; } - if (!isalnum((int)argv[idx_8]->arg[0])) { + if (!isalnum((unsigned char)argv[idx_8]->arg[0])) { vty_out(vty, "Please specify string starting with alphanumeric\n"); return CMD_WARNING_CONFIG_FAILED; @@ -2098,7 +2098,7 @@ DEFUN (config_enable_password, } } - if (!isalnum((int)argv[idx_8]->arg[0])) { + if (!isalnum((unsigned char)argv[idx_8]->arg[0])) { vty_out(vty, "Please specify string starting with alphanumeric\n"); return CMD_WARNING_CONFIG_FAILED; |
