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/arm/ChangeLog | 8 ++++++++ sim/arm/armos.c | 3 ++- sim/arm/armsupp.c | 3 ++- sim/arm/wrapper.c | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) (limited to 'sim/arm') diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog index 2ce9429..488178a 100644 --- a/sim/arm/ChangeLog +++ b/sim/arm/ChangeLog @@ -1,3 +1,11 @@ +2017-02-13 Mike Frysinger + + * armos.c: Include libiberty.h. + (SWIopen): Use ARRAY_SIZE. + * armsupp.c: Include libiberty.h. + (ModeToBank): Use ARRAY_SIZE. + * wrapper.c (sim_target_parse_command_line): Likewise. + 2016-07-14 Nick Clifton * armemu.c (Multiply64): Only issue error messages about invalid diff --git a/sim/arm/armos.c b/sim/arm/armos.c index ea3d229..76c449b 100644 --- a/sim/arm/armos.c +++ b/sim/arm/armos.c @@ -23,6 +23,7 @@ #include "config.h" #include "ansidecl.h" +#include "libiberty.h" #include #include @@ -260,7 +261,7 @@ SWIopen (ARMul_State * state, ARMword name, ARMword SWIflags) return; /* Now we need to decode the Demon open mode. */ - if (SWIflags >= sizeof (translate_open_mode) / sizeof (translate_open_mode[0])) + if (SWIflags >= ARRAY_SIZE (translate_open_mode)) flags = 0; else flags = translate_open_mode[SWIflags]; diff --git a/sim/arm/armsupp.c b/sim/arm/armsupp.c index 3ff4bf9..11bb53c 100644 --- a/sim/arm/armsupp.c +++ b/sim/arm/armsupp.c @@ -17,6 +17,7 @@ #include "armdefs.h" #include "armemu.h" #include "ansidecl.h" +#include "libiberty.h" #include /* Definitions for the support routines. */ @@ -373,7 +374,7 @@ ModeToBank (ARMword mode) DUMMYBANK, DUMMYBANK, DUMMYBANK, SYSTEMBANK }; - if (mode >= (sizeof (bankofmode) / sizeof (bankofmode[0]))) + if (mode >= ARRAY_SIZE (bankofmode)) return DUMMYBANK; return bankofmode[mode]; diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c index efbeef9..01f88d1 100644 --- a/sim/arm/wrapper.c +++ b/sim/arm/wrapper.c @@ -740,7 +740,7 @@ sim_target_parse_command_line (int argc, char ** argv) { int i; - for (i = sizeof options / sizeof options[0]; i--;) + for (i = ARRAY_SIZE (options); i--;) if (strncmp (ptr, options[i].swi_option, strlen (options[i].swi_option)) == 0) { -- cgit v1.1