Commit cd390083ad1fea1ddb93df9c5560eba0a9f26a0d
1 parent
77b9435f
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
Showing
8 changed files
with
43 additions
and
27 deletions
audio/audio.c
| @@ -215,7 +215,7 @@ static char *audio_alloc_prefix (const char *s) | @@ -215,7 +215,7 @@ static char *audio_alloc_prefix (const char *s) | ||
| 215 | pstrcat (r, len + sizeof (qemu_prefix), s); | 215 | pstrcat (r, len + sizeof (qemu_prefix), s); |
| 216 | 216 | ||
| 217 | for (i = 0; i < len; ++i) { | 217 | for (i = 0; i < len; ++i) { |
| 218 | - u[i] = toupper (u[i]); | 218 | + u[i] = qemu_toupper(u[i]); |
| 219 | } | 219 | } |
| 220 | } | 220 | } |
| 221 | return r; | 221 | return r; |
| @@ -470,7 +470,7 @@ static void audio_process_options (const char *prefix, | @@ -470,7 +470,7 @@ static void audio_process_options (const char *prefix, | ||
| 470 | 470 | ||
| 471 | /* copy while upper-casing, including trailing zero */ | 471 | /* copy while upper-casing, including trailing zero */ |
| 472 | for (i = 0; i <= preflen; ++i) { | 472 | for (i = 0; i <= preflen; ++i) { |
| 473 | - optname[i + sizeof (qemu_prefix) - 1] = toupper (prefix[i]); | 473 | + optname[i + sizeof (qemu_prefix) - 1] = qemu_toupper(prefix[i]); |
| 474 | } | 474 | } |
| 475 | pstrcat (optname, optlen, "_"); | 475 | pstrcat (optname, optlen, "_"); |
| 476 | pstrcat (optname, optlen, opt->name); | 476 | pstrcat (optname, optlen, opt->name); |
block-vvfat.c
| @@ -1056,7 +1056,7 @@ DLOG(if (stderr == NULL) { | @@ -1056,7 +1056,7 @@ DLOG(if (stderr == NULL) { | ||
| 1056 | 1056 | ||
| 1057 | i = strrchr(dirname, ':') - dirname; | 1057 | i = strrchr(dirname, ':') - dirname; |
| 1058 | assert(i >= 3); | 1058 | assert(i >= 3); |
| 1059 | - if (dirname[i-2] == ':' && isalpha(dirname[i-1])) | 1059 | + if (dirname[i-2] == ':' && qemu_isalpha(dirname[i-1])) |
| 1060 | /* workaround for DOS drive names */ | 1060 | /* workaround for DOS drive names */ |
| 1061 | dirname += i-1; | 1061 | dirname += i-1; |
| 1062 | else | 1062 | else |
cutils.c
| @@ -72,7 +72,7 @@ int stristart(const char *str, const char *val, const char **ptr) | @@ -72,7 +72,7 @@ int stristart(const char *str, const char *val, const char **ptr) | ||
| 72 | p = str; | 72 | p = str; |
| 73 | q = val; | 73 | q = val; |
| 74 | while (*q != '\0') { | 74 | while (*q != '\0') { |
| 75 | - if (toupper(*p) != toupper(*q)) | 75 | + if (qemu_toupper(*p) != qemu_toupper(*q)) |
| 76 | return 0; | 76 | return 0; |
| 77 | p++; | 77 | p++; |
| 78 | q++; | 78 | q++; |
monitor.c
| @@ -1933,7 +1933,7 @@ static void next(void) | @@ -1933,7 +1933,7 @@ static void next(void) | ||
| 1933 | { | 1933 | { |
| 1934 | if (pch != '\0') { | 1934 | if (pch != '\0') { |
| 1935 | pch++; | 1935 | pch++; |
| 1936 | - while (isspace(*pch)) | 1936 | + while (qemu_isspace(*pch)) |
| 1937 | pch++; | 1937 | pch++; |
| 1938 | } | 1938 | } |
| 1939 | } | 1939 | } |
| @@ -1992,7 +1992,7 @@ static int64_t expr_unary(void) | @@ -1992,7 +1992,7 @@ static int64_t expr_unary(void) | ||
| 1992 | *q++ = *pch; | 1992 | *q++ = *pch; |
| 1993 | pch++; | 1993 | pch++; |
| 1994 | } | 1994 | } |
| 1995 | - while (isspace(*pch)) | 1995 | + while (qemu_isspace(*pch)) |
| 1996 | pch++; | 1996 | pch++; |
| 1997 | *q = 0; | 1997 | *q = 0; |
| 1998 | ret = get_monitor_def(®, buf); | 1998 | ret = get_monitor_def(®, buf); |
| @@ -2017,7 +2017,7 @@ static int64_t expr_unary(void) | @@ -2017,7 +2017,7 @@ static int64_t expr_unary(void) | ||
| 2017 | expr_error("invalid char in expression"); | 2017 | expr_error("invalid char in expression"); |
| 2018 | } | 2018 | } |
| 2019 | pch = p; | 2019 | pch = p; |
| 2020 | - while (isspace(*pch)) | 2020 | + while (qemu_isspace(*pch)) |
| 2021 | pch++; | 2021 | pch++; |
| 2022 | break; | 2022 | break; |
| 2023 | } | 2023 | } |
| @@ -2111,7 +2111,7 @@ static int get_expr(int64_t *pval, const char **pp) | @@ -2111,7 +2111,7 @@ static int get_expr(int64_t *pval, const char **pp) | ||
| 2111 | *pp = pch; | 2111 | *pp = pch; |
| 2112 | return -1; | 2112 | return -1; |
| 2113 | } | 2113 | } |
| 2114 | - while (isspace(*pch)) | 2114 | + while (qemu_isspace(*pch)) |
| 2115 | pch++; | 2115 | pch++; |
| 2116 | *pval = expr_sum(); | 2116 | *pval = expr_sum(); |
| 2117 | *pp = pch; | 2117 | *pp = pch; |
| @@ -2126,7 +2126,7 @@ static int get_str(char *buf, int buf_size, const char **pp) | @@ -2126,7 +2126,7 @@ static int get_str(char *buf, int buf_size, const char **pp) | ||
| 2126 | 2126 | ||
| 2127 | q = buf; | 2127 | q = buf; |
| 2128 | p = *pp; | 2128 | p = *pp; |
| 2129 | - while (isspace(*p)) | 2129 | + while (qemu_isspace(*p)) |
| 2130 | p++; | 2130 | p++; |
| 2131 | if (*p == '\0') { | 2131 | if (*p == '\0') { |
| 2132 | fail: | 2132 | fail: |
| @@ -2171,7 +2171,7 @@ static int get_str(char *buf, int buf_size, const char **pp) | @@ -2171,7 +2171,7 @@ static int get_str(char *buf, int buf_size, const char **pp) | ||
| 2171 | } | 2171 | } |
| 2172 | p++; | 2172 | p++; |
| 2173 | } else { | 2173 | } else { |
| 2174 | - while (*p != '\0' && !isspace(*p)) { | 2174 | + while (*p != '\0' && !qemu_isspace(*p)) { |
| 2175 | if ((q - buf) < buf_size - 1) { | 2175 | if ((q - buf) < buf_size - 1) { |
| 2176 | *q++ = *p; | 2176 | *q++ = *p; |
| 2177 | } | 2177 | } |
| @@ -2217,12 +2217,12 @@ static void monitor_handle_command(const char *cmdline) | @@ -2217,12 +2217,12 @@ static void monitor_handle_command(const char *cmdline) | ||
| 2217 | /* extract the command name */ | 2217 | /* extract the command name */ |
| 2218 | p = cmdline; | 2218 | p = cmdline; |
| 2219 | q = cmdname; | 2219 | q = cmdname; |
| 2220 | - while (isspace(*p)) | 2220 | + while (qemu_isspace(*p)) |
| 2221 | p++; | 2221 | p++; |
| 2222 | if (*p == '\0') | 2222 | if (*p == '\0') |
| 2223 | return; | 2223 | return; |
| 2224 | pstart = p; | 2224 | pstart = p; |
| 2225 | - while (*p != '\0' && *p != '/' && !isspace(*p)) | 2225 | + while (*p != '\0' && *p != '/' && !qemu_isspace(*p)) |
| 2226 | p++; | 2226 | p++; |
| 2227 | len = p - pstart; | 2227 | len = p - pstart; |
| 2228 | if (len > sizeof(cmdname) - 1) | 2228 | if (len > sizeof(cmdname) - 1) |
| @@ -2258,7 +2258,7 @@ static void monitor_handle_command(const char *cmdline) | @@ -2258,7 +2258,7 @@ static void monitor_handle_command(const char *cmdline) | ||
| 2258 | int ret; | 2258 | int ret; |
| 2259 | char *str; | 2259 | char *str; |
| 2260 | 2260 | ||
| 2261 | - while (isspace(*p)) | 2261 | + while (qemu_isspace(*p)) |
| 2262 | p++; | 2262 | p++; |
| 2263 | if (*typestr == '?') { | 2263 | if (*typestr == '?') { |
| 2264 | typestr++; | 2264 | typestr++; |
| @@ -2299,15 +2299,15 @@ static void monitor_handle_command(const char *cmdline) | @@ -2299,15 +2299,15 @@ static void monitor_handle_command(const char *cmdline) | ||
| 2299 | { | 2299 | { |
| 2300 | int count, format, size; | 2300 | int count, format, size; |
| 2301 | 2301 | ||
| 2302 | - while (isspace(*p)) | 2302 | + while (qemu_isspace(*p)) |
| 2303 | p++; | 2303 | p++; |
| 2304 | if (*p == '/') { | 2304 | if (*p == '/') { |
| 2305 | /* format found */ | 2305 | /* format found */ |
| 2306 | p++; | 2306 | p++; |
| 2307 | count = 1; | 2307 | count = 1; |
| 2308 | - if (isdigit(*p)) { | 2308 | + if (qemu_isdigit(*p)) { |
| 2309 | count = 0; | 2309 | count = 0; |
| 2310 | - while (isdigit(*p)) { | 2310 | + while (qemu_isdigit(*p)) { |
| 2311 | count = count * 10 + (*p - '0'); | 2311 | count = count * 10 + (*p - '0'); |
| 2312 | p++; | 2312 | p++; |
| 2313 | } | 2313 | } |
| @@ -2346,7 +2346,7 @@ static void monitor_handle_command(const char *cmdline) | @@ -2346,7 +2346,7 @@ static void monitor_handle_command(const char *cmdline) | ||
| 2346 | } | 2346 | } |
| 2347 | } | 2347 | } |
| 2348 | next: | 2348 | next: |
| 2349 | - if (*p != '\0' && !isspace(*p)) { | 2349 | + if (*p != '\0' && !qemu_isspace(*p)) { |
| 2350 | term_printf("invalid char in format: '%c'\n", *p); | 2350 | term_printf("invalid char in format: '%c'\n", *p); |
| 2351 | goto fail; | 2351 | goto fail; |
| 2352 | } | 2352 | } |
| @@ -2380,7 +2380,7 @@ static void monitor_handle_command(const char *cmdline) | @@ -2380,7 +2380,7 @@ static void monitor_handle_command(const char *cmdline) | ||
| 2380 | { | 2380 | { |
| 2381 | int64_t val; | 2381 | int64_t val; |
| 2382 | 2382 | ||
| 2383 | - while (isspace(*p)) | 2383 | + while (qemu_isspace(*p)) |
| 2384 | p++; | 2384 | p++; |
| 2385 | if (*typestr == '?' || *typestr == '.') { | 2385 | if (*typestr == '?' || *typestr == '.') { |
| 2386 | if (*typestr == '?') { | 2386 | if (*typestr == '?') { |
| @@ -2391,7 +2391,7 @@ static void monitor_handle_command(const char *cmdline) | @@ -2391,7 +2391,7 @@ static void monitor_handle_command(const char *cmdline) | ||
| 2391 | } else { | 2391 | } else { |
| 2392 | if (*p == '.') { | 2392 | if (*p == '.') { |
| 2393 | p++; | 2393 | p++; |
| 2394 | - while (isspace(*p)) | 2394 | + while (qemu_isspace(*p)) |
| 2395 | p++; | 2395 | p++; |
| 2396 | has_arg = 1; | 2396 | has_arg = 1; |
| 2397 | } else { | 2397 | } else { |
| @@ -2436,7 +2436,7 @@ static void monitor_handle_command(const char *cmdline) | @@ -2436,7 +2436,7 @@ static void monitor_handle_command(const char *cmdline) | ||
| 2436 | c = *typestr++; | 2436 | c = *typestr++; |
| 2437 | if (c == '\0') | 2437 | if (c == '\0') |
| 2438 | goto bad_type; | 2438 | goto bad_type; |
| 2439 | - while (isspace(*p)) | 2439 | + while (qemu_isspace(*p)) |
| 2440 | p++; | 2440 | p++; |
| 2441 | has_option = 0; | 2441 | has_option = 0; |
| 2442 | if (*p == '-') { | 2442 | if (*p == '-') { |
| @@ -2461,7 +2461,7 @@ static void monitor_handle_command(const char *cmdline) | @@ -2461,7 +2461,7 @@ static void monitor_handle_command(const char *cmdline) | ||
| 2461 | } | 2461 | } |
| 2462 | } | 2462 | } |
| 2463 | /* check that all arguments were parsed */ | 2463 | /* check that all arguments were parsed */ |
| 2464 | - while (isspace(*p)) | 2464 | + while (qemu_isspace(*p)) |
| 2465 | p++; | 2465 | p++; |
| 2466 | if (*p != '\0') { | 2466 | if (*p != '\0') { |
| 2467 | term_printf("%s: extraneous characters at the end of line\n", | 2467 | term_printf("%s: extraneous characters at the end of line\n", |
| @@ -2609,7 +2609,7 @@ static void parse_cmdline(const char *cmdline, | @@ -2609,7 +2609,7 @@ static void parse_cmdline(const char *cmdline, | ||
| 2609 | p = cmdline; | 2609 | p = cmdline; |
| 2610 | nb_args = 0; | 2610 | nb_args = 0; |
| 2611 | for(;;) { | 2611 | for(;;) { |
| 2612 | - while (isspace(*p)) | 2612 | + while (qemu_isspace(*p)) |
| 2613 | p++; | 2613 | p++; |
| 2614 | if (*p == '\0') | 2614 | if (*p == '\0') |
| 2615 | break; | 2615 | break; |
| @@ -2643,7 +2643,7 @@ void readline_find_completion(const char *cmdline) | @@ -2643,7 +2643,7 @@ void readline_find_completion(const char *cmdline) | ||
| 2643 | /* if the line ends with a space, it means we want to complete the | 2643 | /* if the line ends with a space, it means we want to complete the |
| 2644 | next arg */ | 2644 | next arg */ |
| 2645 | len = strlen(cmdline); | 2645 | len = strlen(cmdline); |
| 2646 | - if (len > 0 && isspace(cmdline[len - 1])) { | 2646 | + if (len > 0 && qemu_isspace(cmdline[len - 1])) { |
| 2647 | if (nb_args >= MAX_ARGS) | 2647 | if (nb_args >= MAX_ARGS) |
| 2648 | return; | 2648 | return; |
| 2649 | args[nb_args++] = qemu_strdup(""); | 2649 | args[nb_args++] = qemu_strdup(""); |
net.c
| @@ -268,7 +268,7 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str) | @@ -268,7 +268,7 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str) | ||
| 268 | if (buf[0] == '\0') { | 268 | if (buf[0] == '\0') { |
| 269 | saddr->sin_addr.s_addr = 0; | 269 | saddr->sin_addr.s_addr = 0; |
| 270 | } else { | 270 | } else { |
| 271 | - if (isdigit(buf[0])) { | 271 | + if (qemu_isdigit(buf[0])) { |
| 272 | if (!inet_aton(buf, &saddr->sin_addr)) | 272 | if (!inet_aton(buf, &saddr->sin_addr)) |
| 273 | return -1; | 273 | return -1; |
| 274 | } else { | 274 | } else { |
qemu-common.h
| @@ -95,6 +95,22 @@ int strstart(const char *str, const char *val, const char **ptr); | @@ -95,6 +95,22 @@ int strstart(const char *str, const char *val, const char **ptr); | ||
| 95 | int stristart(const char *str, const char *val, const char **ptr); | 95 | int stristart(const char *str, const char *val, const char **ptr); |
| 96 | time_t mktimegm(struct tm *tm); | 96 | time_t mktimegm(struct tm *tm); |
| 97 | 97 | ||
| 98 | +#define qemu_isalnum(c) isalnum((unsigned char)(c)) | ||
| 99 | +#define qemu_isalpha(c) isalpha((unsigned char)(c)) | ||
| 100 | +#define qemu_iscntrl(c) iscntrl((unsigned char)(c)) | ||
| 101 | +#define qemu_isdigit(c) isdigit((unsigned char)(c)) | ||
| 102 | +#define qemu_isgraph(c) isgraph((unsigned char)(c)) | ||
| 103 | +#define qemu_islower(c) islower((unsigned char)(c)) | ||
| 104 | +#define qemu_isprint(c) isprint((unsigned char)(c)) | ||
| 105 | +#define qemu_ispunct(c) ispunct((unsigned char)(c)) | ||
| 106 | +#define qemu_isspace(c) isspace((unsigned char)(c)) | ||
| 107 | +#define qemu_isupper(c) isupper((unsigned char)(c)) | ||
| 108 | +#define qemu_isxdigit(c) isxdigit((unsigned char)(c)) | ||
| 109 | +#define qemu_tolower(c) tolower((unsigned char)(c)) | ||
| 110 | +#define qemu_toupper(c) toupper((unsigned char)(c)) | ||
| 111 | +#define qemu_isascii(c) isascii((unsigned char)(c)) | ||
| 112 | +#define qemu_toascii(c) toascii((unsigned char)(c)) | ||
| 113 | + | ||
| 98 | void *qemu_malloc(size_t size); | 114 | void *qemu_malloc(size_t size); |
| 99 | void *qemu_realloc(void *ptr, size_t size); | 115 | void *qemu_realloc(void *ptr, size_t size); |
| 100 | void *qemu_mallocz(size_t size); | 116 | void *qemu_mallocz(size_t size); |
readline.c
| @@ -169,7 +169,7 @@ static void term_backword(void) | @@ -169,7 +169,7 @@ static void term_backword(void) | ||
| 169 | 169 | ||
| 170 | /* find first word (backwards) */ | 170 | /* find first word (backwards) */ |
| 171 | while (start > 0) { | 171 | while (start > 0) { |
| 172 | - if (!isspace(term_cmd_buf[start])) { | 172 | + if (!qemu_isspace(term_cmd_buf[start])) { |
| 173 | break; | 173 | break; |
| 174 | } | 174 | } |
| 175 | 175 | ||
| @@ -178,7 +178,7 @@ static void term_backword(void) | @@ -178,7 +178,7 @@ static void term_backword(void) | ||
| 178 | 178 | ||
| 179 | /* find first space (backwards) */ | 179 | /* find first space (backwards) */ |
| 180 | while (start > 0) { | 180 | while (start > 0) { |
| 181 | - if (isspace(term_cmd_buf[start])) { | 181 | + if (qemu_isspace(term_cmd_buf[start])) { |
| 182 | ++start; | 182 | ++start; |
| 183 | break; | 183 | break; |
| 184 | } | 184 | } |
target-ppc/translate_init.c
| @@ -9458,7 +9458,7 @@ const ppc_def_t *cpu_ppc_find_by_name (const char *name) | @@ -9458,7 +9458,7 @@ const ppc_def_t *cpu_ppc_find_by_name (const char *name) | ||
| 9458 | p = name; | 9458 | p = name; |
| 9459 | check_pvr: | 9459 | check_pvr: |
| 9460 | for (i = 0; i < 8; i++) { | 9460 | for (i = 0; i < 8; i++) { |
| 9461 | - if (!isxdigit(*p++)) | 9461 | + if (!qemu_isxdigit(*p++)) |
| 9462 | break; | 9462 | break; |
| 9463 | } | 9463 | } |
| 9464 | if (i == 8) | 9464 | if (i == 8) |