mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 01:37:53 +00:00
*: 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>
This commit is contained in:
parent
7040d52aaf
commit
fefa5e0ff5
@ -1885,7 +1885,7 @@ static const char *aspath_gettoken(const char *buf, enum as_token *token,
|
|||||||
const char *p = buf;
|
const char *p = buf;
|
||||||
|
|
||||||
/* Skip seperators (space for sequences, ',' for sets). */
|
/* Skip seperators (space for sequences, ',' for sets). */
|
||||||
while (isspace((int)*p) || *p == ',')
|
while (isspace((unsigned char)*p) || *p == ',')
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
/* Check the end of the string and type specify characters
|
/* Check the end of the string and type specify characters
|
||||||
@ -1920,14 +1920,14 @@ static const char *aspath_gettoken(const char *buf, enum as_token *token,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check actual AS value. */
|
/* Check actual AS value. */
|
||||||
if (isdigit((int)*p)) {
|
if (isdigit((unsigned char)*p)) {
|
||||||
as_t asval;
|
as_t asval;
|
||||||
|
|
||||||
*token = as_token_asval;
|
*token = as_token_asval;
|
||||||
asval = (*p - '0');
|
asval = (*p - '0');
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
while (isdigit((int)*p)) {
|
while (isdigit((unsigned char)*p)) {
|
||||||
asval *= 10;
|
asval *= 10;
|
||||||
asval += (*p - '0');
|
asval += (*p - '0');
|
||||||
p++;
|
p++;
|
||||||
|
@ -157,7 +157,7 @@ community_list_insert(struct community_list_handler *ch, const char *name,
|
|||||||
/* If name is made by all digit character. We treat it as
|
/* If name is made by all digit character. We treat it as
|
||||||
number. */
|
number. */
|
||||||
for (number = 0, i = 0; i < strlen(name); i++) {
|
for (number = 0, i = 0; i < strlen(name); i++) {
|
||||||
if (isdigit((int)name[i]))
|
if (isdigit((unsigned char)name[i]))
|
||||||
number = (number * 10) + (name[i] - '0');
|
number = (number * 10) + (name[i] - '0');
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -651,7 +651,7 @@ community_gettoken(const char *buf, enum community_token *token, uint32_t *val)
|
|||||||
const char *p = buf;
|
const char *p = buf;
|
||||||
|
|
||||||
/* Skip white space. */
|
/* Skip white space. */
|
||||||
while (isspace((int)*p))
|
while (isspace((unsigned char)*p))
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
/* Check the end of the line. */
|
/* Check the end of the line. */
|
||||||
@ -659,7 +659,7 @@ community_gettoken(const char *buf, enum community_token *token, uint32_t *val)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Well known community string check. */
|
/* Well known community string check. */
|
||||||
if (isalpha((int)*p)) {
|
if (isalpha((unsigned char)*p)) {
|
||||||
if (strncmp(p, "internet", strlen("internet")) == 0) {
|
if (strncmp(p, "internet", strlen("internet")) == 0) {
|
||||||
*val = COMMUNITY_INTERNET;
|
*val = COMMUNITY_INTERNET;
|
||||||
*token = community_token_no_export;
|
*token = community_token_no_export;
|
||||||
@ -770,13 +770,13 @@ community_gettoken(const char *buf, enum community_token *token, uint32_t *val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Community value. */
|
/* Community value. */
|
||||||
if (isdigit((int)*p)) {
|
if (isdigit((unsigned char)*p)) {
|
||||||
int separator = 0;
|
int separator = 0;
|
||||||
int digit = 0;
|
int digit = 0;
|
||||||
uint32_t community_low = 0;
|
uint32_t community_low = 0;
|
||||||
uint32_t community_high = 0;
|
uint32_t community_high = 0;
|
||||||
|
|
||||||
while (isdigit((int)*p) || *p == ':') {
|
while (isdigit((unsigned char)*p) || *p == ':') {
|
||||||
if (*p == ':') {
|
if (*p == ':') {
|
||||||
if (separator) {
|
if (separator) {
|
||||||
*token = community_token_unknown;
|
*token = community_token_unknown;
|
||||||
|
@ -584,7 +584,7 @@ static unsigned int bgp_dump_parse_time(const char *str)
|
|||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (isdigit((int)str[i])) {
|
if (isdigit((unsigned char)str[i])) {
|
||||||
time *= 10;
|
time *= 10;
|
||||||
time += str[i] - '0';
|
time += str[i] - '0';
|
||||||
} else if (str[i] == 'H' || str[i] == 'h') {
|
} else if (str[i] == 'H' || str[i] == 'h') {
|
||||||
|
@ -352,7 +352,7 @@ static const char *ecommunity_gettoken(const char *str,
|
|||||||
char buf[INET_ADDRSTRLEN + 1];
|
char buf[INET_ADDRSTRLEN + 1];
|
||||||
|
|
||||||
/* Skip white space. */
|
/* Skip white space. */
|
||||||
while (isspace((int)*p)) {
|
while (isspace((unsigned char)*p)) {
|
||||||
p++;
|
p++;
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
@ -362,38 +362,38 @@ static const char *ecommunity_gettoken(const char *str,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* "rt" and "soo" keyword parse. */
|
/* "rt" and "soo" keyword parse. */
|
||||||
if (!isdigit((int)*p)) {
|
if (!isdigit((unsigned char)*p)) {
|
||||||
/* "rt" match check. */
|
/* "rt" match check. */
|
||||||
if (tolower((int)*p) == 'r') {
|
if (tolower((unsigned char)*p) == 'r') {
|
||||||
p++;
|
p++;
|
||||||
if (tolower((int)*p) == 't') {
|
if (tolower((unsigned char)*p) == 't') {
|
||||||
p++;
|
p++;
|
||||||
*token = ecommunity_token_rt;
|
*token = ecommunity_token_rt;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
if (isspace((int)*p) || *p == '\0') {
|
if (isspace((unsigned char)*p) || *p == '\0') {
|
||||||
*token = ecommunity_token_rt;
|
*token = ecommunity_token_rt;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
/* "soo" match check. */
|
/* "soo" match check. */
|
||||||
else if (tolower((int)*p) == 's') {
|
else if (tolower((unsigned char)*p) == 's') {
|
||||||
p++;
|
p++;
|
||||||
if (tolower((int)*p) == 'o') {
|
if (tolower((unsigned char)*p) == 'o') {
|
||||||
p++;
|
p++;
|
||||||
if (tolower((int)*p) == 'o') {
|
if (tolower((unsigned char)*p) == 'o') {
|
||||||
p++;
|
p++;
|
||||||
*token = ecommunity_token_soo;
|
*token = ecommunity_token_soo;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
if (isspace((int)*p) || *p == '\0') {
|
if (isspace((unsigned char)*p) || *p == '\0') {
|
||||||
*token = ecommunity_token_soo;
|
*token = ecommunity_token_soo;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (isspace((int)*p) || *p == '\0') {
|
if (isspace((unsigned char)*p) || *p == '\0') {
|
||||||
*token = ecommunity_token_soo;
|
*token = ecommunity_token_soo;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -415,7 +415,7 @@ static const char *ecommunity_gettoken(const char *str,
|
|||||||
* OPQR: Four byte value
|
* OPQR: Four byte value
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
while (isdigit((int)*p) || *p == ':' || *p == '.') {
|
while (isdigit((unsigned char)*p) || *p == ':' || *p == '.') {
|
||||||
if (*p == ':') {
|
if (*p == ':') {
|
||||||
if (separator)
|
if (separator)
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -193,7 +193,7 @@ static struct as_list *as_list_insert(const char *name)
|
|||||||
/* If name is made by all digit character. We treat it as
|
/* If name is made by all digit character. We treat it as
|
||||||
number. */
|
number. */
|
||||||
for (number = 0, i = 0; i < strlen(name); i++) {
|
for (number = 0, i = 0; i < strlen(name); i++) {
|
||||||
if (isdigit((int)name[i]))
|
if (isdigit((unsigned char)name[i]))
|
||||||
number = (number * 10) + (name[i] - '0');
|
number = (number * 10) + (name[i] - '0');
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -359,7 +359,7 @@ static const char *lcommunity_gettoken(const char *str,
|
|||||||
const char *p = str;
|
const char *p = str;
|
||||||
|
|
||||||
/* Skip white space. */
|
/* Skip white space. */
|
||||||
while (isspace((int)*p)) {
|
while (isspace((unsigned char)*p)) {
|
||||||
p++;
|
p++;
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
@ -369,14 +369,14 @@ static const char *lcommunity_gettoken(const char *str,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Community value. */
|
/* Community value. */
|
||||||
if (isdigit((int)*p)) {
|
if (isdigit((unsigned char)*p)) {
|
||||||
int separator = 0;
|
int separator = 0;
|
||||||
int digit = 0;
|
int digit = 0;
|
||||||
uint32_t globaladmin = 0;
|
uint32_t globaladmin = 0;
|
||||||
uint32_t localdata1 = 0;
|
uint32_t localdata1 = 0;
|
||||||
uint32_t localdata2 = 0;
|
uint32_t localdata2 = 0;
|
||||||
|
|
||||||
while (isdigit((int)*p) || *p == ':') {
|
while (isdigit((unsigned char)*p) || *p == ':') {
|
||||||
if (*p == ':') {
|
if (*p == ':') {
|
||||||
if (separator == 2) {
|
if (separator == 2) {
|
||||||
*token = lcommunity_token_unknown;
|
*token = lcommunity_token_unknown;
|
||||||
|
@ -117,7 +117,8 @@ int dotformat2buff(uint8_t *buff, const char *dotted)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((isxdigit((int)*pos)) && (isxdigit((int)*(pos + 1)))) {
|
if ((isxdigit((unsigned char)*pos)) &&
|
||||||
|
(isxdigit((unsigned char)*(pos + 1)))) {
|
||||||
memcpy(number, pos, 2);
|
memcpy(number, pos, 2);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
} else {
|
} else {
|
||||||
@ -157,7 +158,8 @@ int sysid2buff(uint8_t *buff, const char *dotted)
|
|||||||
pos++;
|
pos++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((isxdigit((int)*pos)) && (isxdigit((int)*(pos + 1)))) {
|
if ((isxdigit((unsigned char)*pos)) &&
|
||||||
|
(isxdigit((unsigned char)*(pos + 1)))) {
|
||||||
memcpy(number, pos, 2);
|
memcpy(number, pos, 2);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1478,7 +1478,7 @@ static int unpack_tlv_dynamic_hostname(enum isis_tlv_context context,
|
|||||||
bool sane = true;
|
bool sane = true;
|
||||||
for (uint8_t i = 0; i < tlv_len; i++) {
|
for (uint8_t i = 0; i < tlv_len; i++) {
|
||||||
if ((unsigned char)tlvs->hostname[i] > 127
|
if ((unsigned char)tlvs->hostname[i] > 127
|
||||||
|| !isprint((int)tlvs->hostname[i])) {
|
|| !isprint((unsigned char)tlvs->hostname[i])) {
|
||||||
sane = false;
|
sane = false;
|
||||||
tlvs->hostname[i] = '?';
|
tlvs->hostname[i] = '?';
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ vector cmd_make_strvec(const char *string)
|
|||||||
const char *copy = string;
|
const char *copy = string;
|
||||||
|
|
||||||
/* skip leading whitespace */
|
/* skip leading whitespace */
|
||||||
while (isspace((int)*copy) && *copy != '\0')
|
while (isspace((unsigned char)*copy) && *copy != '\0')
|
||||||
copy++;
|
copy++;
|
||||||
|
|
||||||
/* if the entire string was whitespace or a comment, return */
|
/* if the entire string was whitespace or a comment, return */
|
||||||
@ -1936,7 +1936,7 @@ DEFUN(config_domainname,
|
|||||||
{
|
{
|
||||||
struct cmd_token *word = argv[1];
|
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");
|
vty_out(vty, "Please specify string starting with alphabet\n");
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
}
|
}
|
||||||
@ -1970,7 +1970,7 @@ DEFUN (config_hostname,
|
|||||||
{
|
{
|
||||||
struct cmd_token *word = argv[1];
|
struct cmd_token *word = argv[1];
|
||||||
|
|
||||||
if (!isalnum((int)word->arg[0])) {
|
if (!isalnum((unsigned char)word->arg[0])) {
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
"Please specify string starting with alphabet or number\n");
|
"Please specify string starting with alphabet or number\n");
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
@ -2018,7 +2018,7 @@ DEFUN (config_password,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isalnum((int)argv[idx_8]->arg[0])) {
|
if (!isalnum((unsigned char)argv[idx_8]->arg[0])) {
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
"Please specify string starting with alphanumeric\n");
|
"Please specify string starting with alphanumeric\n");
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
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,
|
vty_out(vty,
|
||||||
"Please specify string starting with alphanumeric\n");
|
"Please specify string starting with alphanumeric\n");
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
|
@ -97,7 +97,7 @@ void cmd_token_varname_set(struct cmd_token *token, const char *varname)
|
|||||||
token->varname[i] = '_';
|
token->varname[i] = '_';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
token->varname[i] = tolower((int)varname[i]);
|
token->varname[i] = tolower((unsigned char)varname[i]);
|
||||||
}
|
}
|
||||||
token->varname[len] = '\0';
|
token->varname[len] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -714,7 +714,7 @@ static enum match_type match_ipv4(const char *str)
|
|||||||
dots++;
|
dots++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isdigit((int)*str))
|
if (!isdigit((unsigned char)*str))
|
||||||
return no_match;
|
return no_match;
|
||||||
|
|
||||||
str++;
|
str++;
|
||||||
@ -765,7 +765,7 @@ static enum match_type match_ipv4_prefix(const char *str)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isdigit((int)*str))
|
if (!isdigit((unsigned char)*str))
|
||||||
return no_match;
|
return no_match;
|
||||||
|
|
||||||
str++;
|
str++;
|
||||||
@ -797,7 +797,7 @@ static enum match_type match_ipv4_prefix(const char *str)
|
|||||||
|
|
||||||
sp = str;
|
sp = str;
|
||||||
while (*str != '\0') {
|
while (*str != '\0') {
|
||||||
if (!isdigit((int)*str))
|
if (!isdigit((unsigned char)*str))
|
||||||
return no_match;
|
return no_match;
|
||||||
|
|
||||||
str++;
|
str++;
|
||||||
|
@ -273,7 +273,7 @@ static struct access_list *access_list_insert(afi_t afi, const char *name)
|
|||||||
/* If name is made by all digit character. We treat it as
|
/* If name is made by all digit character. We treat it as
|
||||||
number. */
|
number. */
|
||||||
for (number = 0, i = 0; i < strlen(name); i++) {
|
for (number = 0, i = 0; i < strlen(name); i++) {
|
||||||
if (isdigit((int)name[i]))
|
if (isdigit((unsigned char)name[i]))
|
||||||
number = (number * 10) + (name[i] - '0');
|
number = (number * 10) + (name[i] - '0');
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -209,7 +209,7 @@ bool frrstr_endswith(const char *str, const char *suffix)
|
|||||||
int all_digit(const char *str)
|
int all_digit(const char *str)
|
||||||
{
|
{
|
||||||
for (; *str != '\0'; str++)
|
for (; *str != '\0'; str++)
|
||||||
if (!isdigit((int)*str))
|
if (!isdigit((unsigned char)*str))
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
13
lib/log.c
13
lib/log.c
@ -1269,6 +1269,7 @@ void zlog_hexdump(const void *mem, unsigned int len)
|
|||||||
size_t bs = ((len / 8) + 1) * 53 + 1;
|
size_t bs = ((len / 8) + 1) * 53 + 1;
|
||||||
char buf[bs];
|
char buf[bs];
|
||||||
char *s = buf;
|
char *s = buf;
|
||||||
|
const unsigned char *memch = mem;
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
@ -1277,12 +1278,11 @@ void zlog_hexdump(const void *mem, unsigned int len)
|
|||||||
/* print offset */
|
/* print offset */
|
||||||
if (i % columns == 0)
|
if (i % columns == 0)
|
||||||
s += snprintf(s, bs - (s - buf),
|
s += snprintf(s, bs - (s - buf),
|
||||||
"0x%016lx: ", (unsigned long)mem + i);
|
"0x%016lx: ", (unsigned long)memch + i);
|
||||||
|
|
||||||
/* print hex data */
|
/* print hex data */
|
||||||
if (i < len)
|
if (i < len)
|
||||||
s += snprintf(s, bs - (s - buf), "%02x ",
|
s += snprintf(s, bs - (s - buf), "%02x ", memch[i]);
|
||||||
0xFF & ((const char *)mem)[i]);
|
|
||||||
|
|
||||||
/* end of block, just aligning for ASCII dump */
|
/* end of block, just aligning for ASCII dump */
|
||||||
else
|
else
|
||||||
@ -1294,10 +1294,9 @@ void zlog_hexdump(const void *mem, unsigned int len)
|
|||||||
/* end of block not really printing */
|
/* end of block not really printing */
|
||||||
if (j >= len)
|
if (j >= len)
|
||||||
s += snprintf(s, bs - (s - buf), " ");
|
s += snprintf(s, bs - (s - buf), " ");
|
||||||
else if (isprint((int)((const char *)mem)[j]))
|
else if (isprint(memch[j]))
|
||||||
s += snprintf(
|
s += snprintf(s, bs - (s - buf), "%c",
|
||||||
s, bs - (s - buf), "%c",
|
memch[j]);
|
||||||
0xFF & ((const char *)mem)[j]);
|
|
||||||
else /* other char */
|
else /* other char */
|
||||||
s += snprintf(s, bs - (s - buf), ".");
|
s += snprintf(s, bs - (s - buf), ".");
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ static struct prefix_list *prefix_list_insert(afi_t afi, int orf,
|
|||||||
/* If name is made by all digit character. We treat it as
|
/* If name is made by all digit character. We treat it as
|
||||||
number. */
|
number. */
|
||||||
for (number = 0, i = 0; i < strlen(name); i++) {
|
for (number = 0, i = 0; i < strlen(name); i++) {
|
||||||
if (isdigit((int)name[i]))
|
if (isdigit((unsigned char)name[i]))
|
||||||
number = (number * 10) + (name[i] - '0');
|
number = (number * 10) + (name[i] - '0');
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -125,7 +125,7 @@ static int _ptm_lib_decode_header(csv_t *csv, int *msglen, int *version,
|
|||||||
}
|
}
|
||||||
/* remove leading spaces */
|
/* remove leading spaces */
|
||||||
for (i = j = 0; i < csv_field_len(fld); i++) {
|
for (i = j = 0; i < csv_field_len(fld); i++) {
|
||||||
if (!isspace((int)hdr[i])) {
|
if (!isspace((unsigned char)hdr[i])) {
|
||||||
client_name[j] = hdr[i];
|
client_name[j] = hdr[i];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,8 @@ void vty_hello(struct vty *vty)
|
|||||||
/* work backwards to ignore trailling isspace()
|
/* work backwards to ignore trailling isspace()
|
||||||
*/
|
*/
|
||||||
for (s = buf + strlen(buf);
|
for (s = buf + strlen(buf);
|
||||||
(s > buf) && isspace((int)*(s - 1)); s--)
|
(s > buf) && isspace((unsigned char)s[-1]);
|
||||||
|
s--)
|
||||||
;
|
;
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
vty_out(vty, "%s\n", buf);
|
vty_out(vty, "%s\n", buf);
|
||||||
@ -468,7 +469,7 @@ static int vty_command(struct vty *vty, char *buf)
|
|||||||
cp = buf;
|
cp = buf;
|
||||||
if (cp != NULL) {
|
if (cp != NULL) {
|
||||||
/* Skip white spaces. */
|
/* Skip white spaces. */
|
||||||
while (isspace((int)*cp) && *cp != '\0')
|
while (isspace((unsigned char)*cp) && *cp != '\0')
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
if (cp != NULL && *cp != '\0') {
|
if (cp != NULL && *cp != '\0') {
|
||||||
@ -892,7 +893,7 @@ static void vty_complete_command(struct vty *vty)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* In case of 'help \t'. */
|
/* 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);
|
vector_set(vline, NULL);
|
||||||
|
|
||||||
matched = cmd_complete_command(vline, vty, &ret);
|
matched = cmd_complete_command(vline, vty, &ret);
|
||||||
@ -1006,7 +1007,7 @@ static void vty_describe_command(struct vty *vty)
|
|||||||
if (vline == NULL) {
|
if (vline == NULL) {
|
||||||
vline = vector_init(1);
|
vline = vector_init(1);
|
||||||
vector_set(vline, NULL);
|
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);
|
vector_set(vline, NULL);
|
||||||
|
|
||||||
describe = cmd_describe_command(vline, vty, &ret);
|
describe = cmd_describe_command(vline, vty, &ret);
|
||||||
|
@ -243,7 +243,8 @@ static void test_run(struct prng *prng, struct vty *vty, const char *cmd,
|
|||||||
(test_buf[0] != '\0') ? ", " : "",
|
(test_buf[0] != '\0') ? ", " : "",
|
||||||
test_buf);
|
test_buf);
|
||||||
|
|
||||||
if (isspace((int)test_str[strlen(test_str) - 1])) {
|
if (isspace((unsigned char)test_str[
|
||||||
|
strlen(test_str) - 1])) {
|
||||||
vector_set(vline, NULL);
|
vector_set(vline, NULL);
|
||||||
appended_null = 1;
|
appended_null = 1;
|
||||||
}
|
}
|
||||||
|
11
tools/coccinelle/ctype_cast.cocci
Normal file
11
tools/coccinelle/ctype_cast.cocci
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
@@
|
||||||
|
identifier func =~ "^(to|is)(alnum|cntrl|print|xdigit|alpha|digit|punct|ascii|graph|space|blank|lower|upper)$";
|
||||||
|
expression e;
|
||||||
|
@@
|
||||||
|
|
||||||
|
func(
|
||||||
|
- (int)
|
||||||
|
+ (unsigned char)
|
||||||
|
e)
|
||||||
|
|
@ -401,7 +401,7 @@ static void parse_schedule_item(const char *string, struct schedule_item *item)
|
|||||||
|
|
||||||
if (!strcmp(string, "forever")) {
|
if (!strcmp(string, "forever")) {
|
||||||
item->type = sched_forever;
|
item->type = sched_forever;
|
||||||
} else if (isdigit((int)string[0])) {
|
} else if (isdigit((unsigned char)string[0])) {
|
||||||
item->type = sched_timeout;
|
item->type = sched_timeout;
|
||||||
if (parse_integer(string, &item->value) != 0)
|
if (parse_integer(string, &item->value) != 0)
|
||||||
badusage("invalid timeout value in schedule");
|
badusage("invalid timeout value in schedule");
|
||||||
|
@ -668,11 +668,11 @@ static char *trim(char *s)
|
|||||||
return s;
|
return s;
|
||||||
|
|
||||||
end = s + size - 1;
|
end = s + size - 1;
|
||||||
while (end >= s && isspace((int)*end))
|
while (end >= s && isspace((unsigned char)*end))
|
||||||
end--;
|
end--;
|
||||||
*(end + 1) = '\0';
|
*(end + 1) = '\0';
|
||||||
|
|
||||||
while (*s && isspace((int)*s))
|
while (*s && isspace((unsigned char)*s))
|
||||||
s++;
|
s++;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
@ -979,7 +979,7 @@ static int vtysh_process_questionmark(const char *input, int input_len)
|
|||||||
if (vline == NULL) {
|
if (vline == NULL) {
|
||||||
vline = vector_init(1);
|
vline = vector_init(1);
|
||||||
vector_set(vline, NULL);
|
vector_set(vline, NULL);
|
||||||
} else if (input_len && isspace((int)input[input_len - 1]))
|
} else if (input_len && isspace((unsigned char)input[input_len - 1]))
|
||||||
vector_set(vline, NULL);
|
vector_set(vline, NULL);
|
||||||
|
|
||||||
describe = cmd_describe_command(vline, vty, &ret);
|
describe = cmd_describe_command(vline, vty, &ret);
|
||||||
@ -1127,7 +1127,8 @@ static char *command_generator(const char *text, int state)
|
|||||||
if (vline == NULL)
|
if (vline == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (rl_end && isspace((int)rl_line_buffer[rl_end - 1]))
|
if (rl_end &&
|
||||||
|
isspace((unsigned char)rl_line_buffer[rl_end - 1]))
|
||||||
vector_set(vline, NULL);
|
vector_set(vline, NULL);
|
||||||
|
|
||||||
matched = cmd_complete_command(vline, vty, &complete_status);
|
matched = cmd_complete_command(vline, vty, &complete_status);
|
||||||
|
Loading…
Reference in New Issue
Block a user