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/vty.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/vty.c')
| -rw-r--r-- | lib/vty.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -337,7 +337,8 @@ void vty_hello(struct vty *vty) /* work backwards to ignore trailling isspace() */ for (s = buf + strlen(buf); - (s > buf) && isspace((int)*(s - 1)); s--) + (s > buf) && isspace((unsigned char)s[-1]); + s--) ; *s = '\0'; vty_out(vty, "%s\n", buf); @@ -468,7 +469,7 @@ static int vty_command(struct vty *vty, char *buf) cp = buf; if (cp != NULL) { /* Skip white spaces. */ - while (isspace((int)*cp) && *cp != '\0') + while (isspace((unsigned char)*cp) && *cp != '\0') cp++; } if (cp != NULL && *cp != '\0') { @@ -892,7 +893,7 @@ static void vty_complete_command(struct vty *vty) return; /* In case of 'help \t'. */ - if (isspace((int)vty->buf[vty->length - 1])) + if (isspace((unsigned char)vty->buf[vty->length - 1])) vector_set(vline, NULL); matched = cmd_complete_command(vline, vty, &ret); @@ -1006,7 +1007,7 @@ static void vty_describe_command(struct vty *vty) if (vline == NULL) { vline = vector_init(1); vector_set(vline, NULL); - } else if (isspace((int)vty->buf[vty->length - 1])) + } else if (isspace((unsigned char)vty->buf[vty->length - 1])) vector_set(vline, NULL); describe = cmd_describe_command(vline, vty, &ret); |
