From: Jeff Garzik <jeff@garzik.org>
To: wim@iguana.be, Andrew Morton <akpm@osdl.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] watchdog/iTCO_wdt: fix bug related to gcc uninit warning
Date: Tue, 10 Oct 2006 03:40:44 -0400 [thread overview]
Message-ID: <20061010074044.GA23501@havoc.gtf.org> (raw)
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>
---
drivers/char/watchdog/iTCO_wdt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
index aaac94d..bf5cd55 100644
--- a/drivers/char/watchdog/iTCO_wdt.c
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -355,7 +355,8 @@ static int iTCO_wdt_get_timeleft (int *t
spin_unlock(&iTCO_wdt_private.io_lock);
*time_left = (val8 * 6) / 10;
- }
+ } else
+ return -EINVAL;
return 0;
}
@@ -426,7 +427,6 @@ static int iTCO_wdt_ioctl (struct inode
{
int new_options, retval = -EINVAL;
int new_heartbeat;
- int time_left;
void __user *argp = (void __user *)arg;
int __user *p = argp;
static struct watchdog_info ident = {
@@ -486,6 +486,8 @@ static int iTCO_wdt_ioctl (struct inode
case WDIOC_GETTIMELEFT:
{
+ int time_left;
+
if (iTCO_wdt_get_timeleft(&time_left))
return -EINVAL;
next reply other threads:[~2006-10-10 7:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-10 7:40 Jeff Garzik [this message]
2006-10-11 21:14 ` Wim Van Sebroeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061010074044.GA23501@havoc.gtf.org \
--to=jeff@garzik.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wim@iguana.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®