Commit 068abdc8a57023eeafe1025b964a50f8a39929b4
1 parent
8a84de23
Fix inconsistent end conditions in ppc_find_xxx functions.
(crash reported by Andreas Farber when using default CPU). git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3293 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
9 additions
and
8 deletions
target-ppc/translate_init.c
... | ... | @@ -5872,11 +5872,12 @@ int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def) |
5872 | 5872 | |
5873 | 5873 | int ppc_find_by_name (const unsigned char *name, ppc_def_t **def) |
5874 | 5874 | { |
5875 | - int i, ret; | |
5875 | + int i, max, ret; | |
5876 | 5876 | |
5877 | 5877 | ret = -1; |
5878 | 5878 | *def = NULL; |
5879 | - for (i = 0; strcmp(ppc_defs[i].name, "default") != 0; i++) { | |
5879 | + max = sizeof(ppc_defs) / sizeof(ppc_def_t); | |
5880 | + for (i = 0; i < max; i++) { | |
5880 | 5881 | if (strcasecmp(name, ppc_defs[i].name) == 0) { |
5881 | 5882 | *def = &ppc_defs[i]; |
5882 | 5883 | ret = 0; |
... | ... | @@ -5889,11 +5890,12 @@ int ppc_find_by_name (const unsigned char *name, ppc_def_t **def) |
5889 | 5890 | |
5890 | 5891 | int ppc_find_by_pvr (uint32_t pvr, ppc_def_t **def) |
5891 | 5892 | { |
5892 | - int i, ret; | |
5893 | + int i, max, ret; | |
5893 | 5894 | |
5894 | 5895 | ret = -1; |
5895 | 5896 | *def = NULL; |
5896 | - for (i = 0; ppc_defs[i].name != NULL; i++) { | |
5897 | + max = sizeof(ppc_defs) / sizeof(ppc_def_t); | |
5898 | + for (i = 0; i < max; i++) { | |
5897 | 5899 | if ((pvr & ppc_defs[i].pvr_mask) == |
5898 | 5900 | (ppc_defs[i].pvr & ppc_defs[i].pvr_mask)) { |
5899 | 5901 | *def = &ppc_defs[i]; |
... | ... | @@ -5907,12 +5909,11 @@ int ppc_find_by_pvr (uint32_t pvr, ppc_def_t **def) |
5907 | 5909 | |
5908 | 5910 | void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
5909 | 5911 | { |
5910 | - int i; | |
5912 | + int i, max; | |
5911 | 5913 | |
5912 | - for (i = 0; ; i++) { | |
5914 | + max = sizeof(ppc_defs) / sizeof(ppc_def_t); | |
5915 | + for (i = 0; i < max; i++) { | |
5913 | 5916 | (*cpu_fprintf)(f, "PowerPC %-16s PVR %08x\n", |
5914 | 5917 | ppc_defs[i].name, ppc_defs[i].pvr); |
5915 | - if (strcmp(ppc_defs[i].name, "default") == 0) | |
5916 | - break; | |
5917 | 5918 | } |
5918 | 5919 | } | ... | ... |