summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-07-28 09:08:49 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-07-28 09:08:49 +0000
commitacbd9bd0c8c1b00a0130cdab6a14d74224c243f9 (patch)
tree1ef76f0bc2f9e3f37da700389964308f601f36fc
parent182d786cb119bae2692a1ab0346c46547087a994 (diff)
downloadrockbox-acbd9bd0c8c1b00a0130cdab6a14d74224c243f9.tar.gz
rockbox-acbd9bd0c8c1b00a0130cdab6a14d74224c243f9.zip
TP Diffenbach pointed out the risk here. Added a check for bad input values
here, and I also made the argument named 'index' and made it unsigned to better match what it actually is used for. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3899 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/backlight.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 887e5943f1..5173d7819c 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -39,7 +39,7 @@ static bool charger_was_inserted = 0;
39static bool backlight_on_when_charging = 0; 39static bool backlight_on_when_charging = 0;
40 40
41static int backlight_timer; 41static int backlight_timer;
42static int backlight_timeout = 5; 42static unsigned int backlight_timeout = 5;
43 43
44const char backlight_timeout_value[19] = 44const char backlight_timeout_value[19] =
45{ 45{
@@ -125,9 +125,12 @@ int backlight_get_timeout(void)
125 return backlight_timeout; 125 return backlight_timeout;
126} 126}
127 127
128void backlight_set_timeout(int seconds) 128void backlight_set_timeout(unsigned int index)
129{ 129{
130 backlight_timeout = seconds; 130 if(index >= sizeof(backlight_timeout_value))
131 /* if given a weird value, use 0 */
132 index=0;
133 backlight_timeout = index; /* index in the backlight_timeout_value table */
131 backlight_on(); 134 backlight_on();
132} 135}
133 136