From a2ab719d57c2da0a66ece6d6ab1e2eb2a9192413 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Mon, 21 Jun 2010 00:03:15 +0000 Subject: debug menu: avoid using constant variables in array initialization gcc fails to consider indexes as constant when building with -O0 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27002 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'apps/debug_menu.c') diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 9b4ba51815..8da022453d 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -1670,20 +1670,19 @@ static bool view_battery(void) #elif defined(SANSA_E200) || defined(SANSA_C200) || CONFIG_CPU == AS3525 || \ CONFIG_CPU == AS3525v2 - const int first = CHARGE_STATE_DISABLED; static const char * const chrgstate_strings[] = { - [CHARGE_STATE_DISABLED-first] = "Disabled", - [CHARGE_STATE_ERROR-first] = "Error", - [DISCHARGING-first] = "Discharging", - [CHARGING-first] = "Charging", + [CHARGE_STATE_DISABLED - CHARGE_STATE_DISABLED]= "Disabled", + [CHARGE_STATE_ERROR - CHARGE_STATE_DISABLED] = "Error", + [DISCHARGING - CHARGE_STATE_DISABLED] = "Discharging", + [CHARGING - CHARGE_STATE_DISABLED] = "Charging", }; const char *str = NULL; lcd_putsf(0, 3, "Charger: %s", charger_inserted() ? "present" : "absent"); - y = charge_state - first; + y = charge_state - CHARGE_STATE_DISABLED; if ((unsigned)y < ARRAYLEN(chrgstate_strings)) str = chrgstate_strings[y]; -- cgit v1.2.3