提交 80060362 编写于 作者: J Jeff Garzik 提交者: Wim Van Sebroeck

[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: NJeff Garzik <jeff@garzik.org>
Signed-off-by: NWim Van Sebroeck <wim@iguana.be>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
上级 a8edd74e
...@@ -368,7 +368,8 @@ static int iTCO_wdt_get_timeleft (int *time_left) ...@@ -368,7 +368,8 @@ static int iTCO_wdt_get_timeleft (int *time_left)
spin_unlock(&iTCO_wdt_private.io_lock); spin_unlock(&iTCO_wdt_private.io_lock);
*time_left = (val8 * 6) / 10; *time_left = (val8 * 6) / 10;
} } else
return -EINVAL;
return 0; return 0;
} }
...@@ -439,7 +440,6 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file, ...@@ -439,7 +440,6 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file,
{ {
int new_options, retval = -EINVAL; int new_options, retval = -EINVAL;
int new_heartbeat; int new_heartbeat;
int time_left;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int __user *p = argp; int __user *p = argp;
static struct watchdog_info ident = { static struct watchdog_info ident = {
...@@ -499,6 +499,8 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file, ...@@ -499,6 +499,8 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file,
case WDIOC_GETTIMELEFT: case WDIOC_GETTIMELEFT:
{ {
int time_left;
if (iTCO_wdt_get_timeleft(&time_left)) if (iTCO_wdt_get_timeleft(&time_left))
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册