Attached patch fixes a series of this warning

when compiling on NetBSD:

warning: array subscript has type 'char'

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5727 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
blueswir1 2008-11-16 13:53:32 +00:00
parent 77b9435f13
commit cd390083ad
8 changed files with 43 additions and 27 deletions

View File

@ -215,7 +215,7 @@ static char *audio_alloc_prefix (const char *s)
pstrcat (r, len + sizeof (qemu_prefix), s); pstrcat (r, len + sizeof (qemu_prefix), s);
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
u[i] = toupper (u[i]); u[i] = qemu_toupper(u[i]);
} }
} }
return r; return r;
@ -470,7 +470,7 @@ static void audio_process_options (const char *prefix,
/* copy while upper-casing, including trailing zero */ /* copy while upper-casing, including trailing zero */
for (i = 0; i <= preflen; ++i) { for (i = 0; i <= preflen; ++i) {
optname[i + sizeof (qemu_prefix) - 1] = toupper (prefix[i]); optname[i + sizeof (qemu_prefix) - 1] = qemu_toupper(prefix[i]);
} }
pstrcat (optname, optlen, "_"); pstrcat (optname, optlen, "_");
pstrcat (optname, optlen, opt->name); pstrcat (optname, optlen, opt->name);

View File

@ -1056,7 +1056,7 @@ DLOG(if (stderr == NULL) {
i = strrchr(dirname, ':') - dirname; i = strrchr(dirname, ':') - dirname;
assert(i >= 3); assert(i >= 3);
if (dirname[i-2] == ':' && isalpha(dirname[i-1])) if (dirname[i-2] == ':' && qemu_isalpha(dirname[i-1]))
/* workaround for DOS drive names */ /* workaround for DOS drive names */
dirname += i-1; dirname += i-1;
else else

View File

@ -72,7 +72,7 @@ int stristart(const char *str, const char *val, const char **ptr)
p = str; p = str;
q = val; q = val;
while (*q != '\0') { while (*q != '\0') {
if (toupper(*p) != toupper(*q)) if (qemu_toupper(*p) != qemu_toupper(*q))
return 0; return 0;
p++; p++;
q++; q++;

View File

@ -1933,7 +1933,7 @@ static void next(void)
{ {
if (pch != '\0') { if (pch != '\0') {
pch++; pch++;
while (isspace(*pch)) while (qemu_isspace(*pch))
pch++; pch++;
} }
} }
@ -1992,7 +1992,7 @@ static int64_t expr_unary(void)
*q++ = *pch; *q++ = *pch;
pch++; pch++;
} }
while (isspace(*pch)) while (qemu_isspace(*pch))
pch++; pch++;
*q = 0; *q = 0;
ret = get_monitor_def(&reg, buf); ret = get_monitor_def(&reg, buf);
@ -2017,7 +2017,7 @@ static int64_t expr_unary(void)
expr_error("invalid char in expression"); expr_error("invalid char in expression");
} }
pch = p; pch = p;
while (isspace(*pch)) while (qemu_isspace(*pch))
pch++; pch++;
break; break;
} }
@ -2111,7 +2111,7 @@ static int get_expr(int64_t *pval, const char **pp)
*pp = pch; *pp = pch;
return -1; return -1;
} }
while (isspace(*pch)) while (qemu_isspace(*pch))
pch++; pch++;
*pval = expr_sum(); *pval = expr_sum();
*pp = pch; *pp = pch;
@ -2126,7 +2126,7 @@ static int get_str(char *buf, int buf_size, const char **pp)
q = buf; q = buf;
p = *pp; p = *pp;
while (isspace(*p)) while (qemu_isspace(*p))
p++; p++;
if (*p == '\0') { if (*p == '\0') {
fail: fail:
@ -2171,7 +2171,7 @@ static int get_str(char *buf, int buf_size, const char **pp)
} }
p++; p++;
} else { } else {
while (*p != '\0' && !isspace(*p)) { while (*p != '\0' && !qemu_isspace(*p)) {
if ((q - buf) < buf_size - 1) { if ((q - buf) < buf_size - 1) {
*q++ = *p; *q++ = *p;
} }
@ -2217,12 +2217,12 @@ static void monitor_handle_command(const char *cmdline)
/* extract the command name */ /* extract the command name */
p = cmdline; p = cmdline;
q = cmdname; q = cmdname;
while (isspace(*p)) while (qemu_isspace(*p))
p++; p++;
if (*p == '\0') if (*p == '\0')
return; return;
pstart = p; pstart = p;
while (*p != '\0' && *p != '/' && !isspace(*p)) while (*p != '\0' && *p != '/' && !qemu_isspace(*p))
p++; p++;
len = p - pstart; len = p - pstart;
if (len > sizeof(cmdname) - 1) if (len > sizeof(cmdname) - 1)
@ -2258,7 +2258,7 @@ static void monitor_handle_command(const char *cmdline)
int ret; int ret;
char *str; char *str;
while (isspace(*p)) while (qemu_isspace(*p))
p++; p++;
if (*typestr == '?') { if (*typestr == '?') {
typestr++; typestr++;
@ -2299,15 +2299,15 @@ static void monitor_handle_command(const char *cmdline)
{ {
int count, format, size; int count, format, size;
while (isspace(*p)) while (qemu_isspace(*p))
p++; p++;
if (*p == '/') { if (*p == '/') {
/* format found */ /* format found */
p++; p++;
count = 1; count = 1;
if (isdigit(*p)) { if (qemu_isdigit(*p)) {
count = 0; count = 0;
while (isdigit(*p)) { while (qemu_isdigit(*p)) {
count = count * 10 + (*p - '0'); count = count * 10 + (*p - '0');
p++; p++;
} }
@ -2346,7 +2346,7 @@ static void monitor_handle_command(const char *cmdline)
} }
} }
next: next:
if (*p != '\0' && !isspace(*p)) { if (*p != '\0' && !qemu_isspace(*p)) {
term_printf("invalid char in format: '%c'\n", *p); term_printf("invalid char in format: '%c'\n", *p);
goto fail; goto fail;
} }
@ -2380,7 +2380,7 @@ static void monitor_handle_command(const char *cmdline)
{ {
int64_t val; int64_t val;
while (isspace(*p)) while (qemu_isspace(*p))
p++; p++;
if (*typestr == '?' || *typestr == '.') { if (*typestr == '?' || *typestr == '.') {
if (*typestr == '?') { if (*typestr == '?') {
@ -2391,7 +2391,7 @@ static void monitor_handle_command(const char *cmdline)
} else { } else {
if (*p == '.') { if (*p == '.') {
p++; p++;
while (isspace(*p)) while (qemu_isspace(*p))
p++; p++;
has_arg = 1; has_arg = 1;
} else { } else {
@ -2436,7 +2436,7 @@ static void monitor_handle_command(const char *cmdline)
c = *typestr++; c = *typestr++;
if (c == '\0') if (c == '\0')
goto bad_type; goto bad_type;
while (isspace(*p)) while (qemu_isspace(*p))
p++; p++;
has_option = 0; has_option = 0;
if (*p == '-') { if (*p == '-') {
@ -2461,7 +2461,7 @@ static void monitor_handle_command(const char *cmdline)
} }
} }
/* check that all arguments were parsed */ /* check that all arguments were parsed */
while (isspace(*p)) while (qemu_isspace(*p))
p++; p++;
if (*p != '\0') { if (*p != '\0') {
term_printf("%s: extraneous characters at the end of line\n", term_printf("%s: extraneous characters at the end of line\n",
@ -2609,7 +2609,7 @@ static void parse_cmdline(const char *cmdline,
p = cmdline; p = cmdline;
nb_args = 0; nb_args = 0;
for(;;) { for(;;) {
while (isspace(*p)) while (qemu_isspace(*p))
p++; p++;
if (*p == '\0') if (*p == '\0')
break; break;
@ -2643,7 +2643,7 @@ void readline_find_completion(const char *cmdline)
/* if the line ends with a space, it means we want to complete the /* if the line ends with a space, it means we want to complete the
next arg */ next arg */
len = strlen(cmdline); len = strlen(cmdline);
if (len > 0 && isspace(cmdline[len - 1])) { if (len > 0 && qemu_isspace(cmdline[len - 1])) {
if (nb_args >= MAX_ARGS) if (nb_args >= MAX_ARGS)
return; return;
args[nb_args++] = qemu_strdup(""); args[nb_args++] = qemu_strdup("");

2
net.c
View File

@ -268,7 +268,7 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str)
if (buf[0] == '\0') { if (buf[0] == '\0') {
saddr->sin_addr.s_addr = 0; saddr->sin_addr.s_addr = 0;
} else { } else {
if (isdigit(buf[0])) { if (qemu_isdigit(buf[0])) {
if (!inet_aton(buf, &saddr->sin_addr)) if (!inet_aton(buf, &saddr->sin_addr))
return -1; return -1;
} else { } else {

View File

@ -95,6 +95,22 @@ int strstart(const char *str, const char *val, const char **ptr);
int stristart(const char *str, const char *val, const char **ptr); int stristart(const char *str, const char *val, const char **ptr);
time_t mktimegm(struct tm *tm); time_t mktimegm(struct tm *tm);
#define qemu_isalnum(c) isalnum((unsigned char)(c))
#define qemu_isalpha(c) isalpha((unsigned char)(c))
#define qemu_iscntrl(c) iscntrl((unsigned char)(c))
#define qemu_isdigit(c) isdigit((unsigned char)(c))
#define qemu_isgraph(c) isgraph((unsigned char)(c))
#define qemu_islower(c) islower((unsigned char)(c))
#define qemu_isprint(c) isprint((unsigned char)(c))
#define qemu_ispunct(c) ispunct((unsigned char)(c))
#define qemu_isspace(c) isspace((unsigned char)(c))
#define qemu_isupper(c) isupper((unsigned char)(c))
#define qemu_isxdigit(c) isxdigit((unsigned char)(c))
#define qemu_tolower(c) tolower((unsigned char)(c))
#define qemu_toupper(c) toupper((unsigned char)(c))
#define qemu_isascii(c) isascii((unsigned char)(c))
#define qemu_toascii(c) toascii((unsigned char)(c))
void *qemu_malloc(size_t size); void *qemu_malloc(size_t size);
void *qemu_realloc(void *ptr, size_t size); void *qemu_realloc(void *ptr, size_t size);
void *qemu_mallocz(size_t size); void *qemu_mallocz(size_t size);

View File

@ -169,7 +169,7 @@ static void term_backword(void)
/* find first word (backwards) */ /* find first word (backwards) */
while (start > 0) { while (start > 0) {
if (!isspace(term_cmd_buf[start])) { if (!qemu_isspace(term_cmd_buf[start])) {
break; break;
} }
@ -178,7 +178,7 @@ static void term_backword(void)
/* find first space (backwards) */ /* find first space (backwards) */
while (start > 0) { while (start > 0) {
if (isspace(term_cmd_buf[start])) { if (qemu_isspace(term_cmd_buf[start])) {
++start; ++start;
break; break;
} }

View File

@ -9458,7 +9458,7 @@ const ppc_def_t *cpu_ppc_find_by_name (const char *name)
p = name; p = name;
check_pvr: check_pvr:
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if (!isxdigit(*p++)) if (!qemu_isxdigit(*p++))
break; break;
} }
if (i == 8) if (i == 8)