diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-10-10 03:40:44 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2006-10-11 17:12:31 -0400 |
commit | 80060362aaefec507ac2d7a7bd156716d7a7ca91 (patch) | |
tree | a8c97880324f12aeeeded9cec6d3908ac95cc2d9 /drivers/char/watchdog/iTCO_wdt.c | |
parent | a8edd74e4404d011ab821d5bf35b27335d26f001 (diff) |
[WATCHDOG] watchdog/iTCO_wdt: fix bug related to gcc uninit warning
gcc emits the following warning:
drivers/char/watchdog/iTCO_wdt.c: In function ‘iTCO_wdt_ioctl’:
drivers/char/watchdog/iTCO_wdt.c:429: warning: ‘time_left’ may be used uninitialized in this function
This indicates a condition near enough to a bug, to want to fix.
iTCO_wdt_get_timeleft() stores a value in 'time_left' iff
iTCO_version==(1 or 2). This driver only supports versions
1 or 2, so this is ok. However, since (a) the return value of
iTCO_wdt_get_timeleft() is handled anyway, (b) it fixes the warning,
and (c) it future-proofs the driver, we go ahead and add the obvious
return value.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Diffstat (limited to 'drivers/char/watchdog/iTCO_wdt.c')
-rw-r--r-- | drivers/char/watchdog/iTCO_wdt.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c index 505aae917764..b6f29cb8bd39 100644 --- a/drivers/char/watchdog/iTCO_wdt.c +++ b/drivers/char/watchdog/iTCO_wdt.c | |||
@@ -368,7 +368,8 @@ static int iTCO_wdt_get_timeleft (int *time_left) | |||
368 | spin_unlock(&iTCO_wdt_private.io_lock); | 368 | spin_unlock(&iTCO_wdt_private.io_lock); |
369 | 369 | ||
370 | *time_left = (val8 * 6) / 10; | 370 | *time_left = (val8 * 6) / 10; |
371 | } | 371 | } else |
372 | return -EINVAL; | ||
372 | return 0; | 373 | return 0; |
373 | } | 374 | } |
374 | 375 | ||
@@ -439,7 +440,6 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file, | |||
439 | { | 440 | { |
440 | int new_options, retval = -EINVAL; | 441 | int new_options, retval = -EINVAL; |
441 | int new_heartbeat; | 442 | int new_heartbeat; |
442 | int time_left; | ||
443 | void __user *argp = (void __user *)arg; | 443 | void __user *argp = (void __user *)arg; |
444 | int __user *p = argp; | 444 | int __user *p = argp; |
445 | static struct watchdog_info ident = { | 445 | static struct watchdog_info ident = { |
@@ -499,6 +499,8 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file, | |||
499 | 499 | ||
500 | case WDIOC_GETTIMELEFT: | 500 | case WDIOC_GETTIMELEFT: |
501 | { | 501 | { |
502 | int time_left; | ||
503 | |||
502 | if (iTCO_wdt_get_timeleft(&time_left)) | 504 | if (iTCO_wdt_get_timeleft(&time_left)) |
503 | return -EINVAL; | 505 | return -EINVAL; |
504 | 506 | ||