From 13a590ca65f744c8fa55d6e0748cb12f443493f0 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 13 Feb 2017 00:12:35 -0500 Subject: sim: use ARRAY_SIZE instead of ad-hoc sizeof calculations --- sim/cris/ChangeLog | 6 ++++++ sim/cris/decodev10.c | 2 +- sim/cris/decodev32.c | 2 +- sim/cris/sim-if.c | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) (limited to 'sim/cris') diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog index ef96ec7..1257a9e 100644 --- a/sim/cris/ChangeLog +++ b/sim/cris/ChangeLog @@ -1,3 +1,9 @@ +2017-02-13 Mike Frysinger + + * decodev10.c (crisv10f_init_idesc_table): Use ARRAY_SIZE. + * decodev32.c (crisv32f_init_idesc_table): Likewise. + * sim-if.c (sim_open): Likewise. + 2016-01-10 Mike Frysinger * config.in, configure: Regenerate. diff --git a/sim/cris/decodev10.c b/sim/cris/decodev10.c index c4c174f..d9242e3 100644 --- a/sim/cris/decodev10.c +++ b/sim/cris/decodev10.c @@ -302,7 +302,7 @@ crisv10f_init_idesc_table (SIM_CPU *cpu) init_idesc (cpu, id, t); /* Now fill in the values for the chosen cpu. */ - for (t = crisv10f_insn_sem, tend = t + sizeof (crisv10f_insn_sem) / sizeof (*t); + for (t = crisv10f_insn_sem, tend = t + ARRAY_SIZE (crisv10f_insn_sem); t != tend; ++t) { init_idesc (cpu, & table[t->index], t); diff --git a/sim/cris/decodev32.c b/sim/cris/decodev32.c index 4ea146d..10162e8 100644 --- a/sim/cris/decodev32.c +++ b/sim/cris/decodev32.c @@ -306,7 +306,7 @@ crisv32f_init_idesc_table (SIM_CPU *cpu) init_idesc (cpu, id, t); /* Now fill in the values for the chosen cpu. */ - for (t = crisv32f_insn_sem, tend = t + sizeof (crisv32f_insn_sem) / sizeof (*t); + for (t = crisv32f_insn_sem, tend = t + ARRAY_SIZE (crisv32f_insn_sem); t != tend; ++t) { init_idesc (cpu, & table[t->index], t); diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c index 8e3b667..2ccb528 100644 --- a/sim/cris/sim-if.c +++ b/sim/cris/sim-if.c @@ -786,7 +786,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, /* Note that the linux kernel does not correctly compute the storage needs for the static-exe AUX vector. */ - csp -= sizeof (auxv_entries) / sizeof (auxv_entries[0]) * 4 * 2; + csp -= ARRAY_SIZE (auxv_entries) * 4 * 2; csp -= (envc + 1) * 4; csp -= (my_argc + 1) * 4; @@ -874,7 +874,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, goto abandon_chip; if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) - for (i = 0; i < sizeof (auxv_entries) / sizeof (auxv_entries[0]); i++) + for (i = 0; i < ARRAY_SIZE (auxv_entries); i++) { write_dword (csp, auxv_entries[i].id); write_dword (csp + 4, -- cgit v1.1