aboutsummaryrefslogtreecommitdiff
path: root/target-ppc/translate_init.c
diff options
context:
space:
mode:
authorj_mayer <j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162>2007-09-30 14:52:08 +0000
committerj_mayer <j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162>2007-09-30 14:52:08 +0000
commit068abdc8a57023eeafe1025b964a50f8a39929b4 (patch)
tree14647ccefc9c00bd1d9ba6e8146110edf2fd895a /target-ppc/translate_init.c
parent8a84de23b8f8fc63338dfcc58f572e33c428c1b7 (diff)
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
Diffstat (limited to 'target-ppc/translate_init.c')
-rw-r--r--target-ppc/translate_init.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 285e351432..13069c53ec 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -5872,11 +5872,12 @@ int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def)
int ppc_find_by_name (const unsigned char *name, ppc_def_t **def)
{
- int i, ret;
+ int i, max, ret;
ret = -1;
*def = NULL;
- for (i = 0; strcmp(ppc_defs[i].name, "default") != 0; i++) {
+ max = sizeof(ppc_defs) / sizeof(ppc_def_t);
+ for (i = 0; i < max; i++) {
if (strcasecmp(name, ppc_defs[i].name) == 0) {
*def = &ppc_defs[i];
ret = 0;
@@ -5889,11 +5890,12 @@ int ppc_find_by_name (const unsigned char *name, ppc_def_t **def)
int ppc_find_by_pvr (uint32_t pvr, ppc_def_t **def)
{
- int i, ret;
+ int i, max, ret;
ret = -1;
*def = NULL;
- for (i = 0; ppc_defs[i].name != NULL; i++) {
+ max = sizeof(ppc_defs) / sizeof(ppc_def_t);
+ for (i = 0; i < max; i++) {
if ((pvr & ppc_defs[i].pvr_mask) ==
(ppc_defs[i].pvr & ppc_defs[i].pvr_mask)) {
*def = &ppc_defs[i];
@@ -5907,12 +5909,11 @@ int ppc_find_by_pvr (uint32_t pvr, ppc_def_t **def)
void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
- int i;
+ int i, max;
- for (i = 0; ; i++) {
+ max = sizeof(ppc_defs) / sizeof(ppc_def_t);
+ for (i = 0; i < max; i++) {
(*cpu_fprintf)(f, "PowerPC %-16s PVR %08x\n",
ppc_defs[i].name, ppc_defs[i].pvr);
- if (strcmp(ppc_defs[i].name, "default") == 0)
- break;
}
}