diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-07-28 09:08:49 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-07-28 09:08:49 +0000 |
commit | acbd9bd0c8c1b00a0130cdab6a14d74224c243f9 (patch) | |
tree | 1ef76f0bc2f9e3f37da700389964308f601f36fc | |
parent | 182d786cb119bae2692a1ab0346c46547087a994 (diff) | |
download | rockbox-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.c | 9 |
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; | |||
39 | static bool backlight_on_when_charging = 0; | 39 | static bool backlight_on_when_charging = 0; |
40 | 40 | ||
41 | static int backlight_timer; | 41 | static int backlight_timer; |
42 | static int backlight_timeout = 5; | 42 | static unsigned int backlight_timeout = 5; |
43 | 43 | ||
44 | const char backlight_timeout_value[19] = | 44 | const 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 | ||
128 | void backlight_set_timeout(int seconds) | 128 | void 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 | ||