linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] UBI: silence warning about possibly uninitialized use of variable in drivers/mtd/ubi/vmt.c ...
@ 2007-12-13 22:53 Jesper Juhl
  2007-12-15 11:18 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2007-12-13 22:53 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: linux-mtd, LKML, Jesper Juhl

From: Jesper Juhl <jesper.juhl@gmail.com>

This patch silences the following warning :

  drivers/mtd/ubi/vmt.c:73: warning: 'ret' may be used uninitialized in this function

gcc can't see that we always initialize ret in all situations where it is 
actually used. The one case where it's not initialized is when we BUG(), 
but gcc doesn't know that we won't then continue and use an uninitialized 
'ret'.

This patch results in code that does exactely the same as before, but it 
also makes gcc shut up, so we generate one less line of warning noise.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 vmt.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 88629a3..e44948d 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -70,13 +70,14 @@ static struct device_attribute attr_vol_upd_marker =
 static ssize_t vol_attribute_show(struct device *dev,
 				  struct device_attribute *attr, char *buf)
 {
-	int ret;
+	int ret = -ENODEV;
+
 	struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev);
 
 	spin_lock(&vol->ubi->volumes_lock);
 	if (vol->removed) {
 		spin_unlock(&vol->ubi->volumes_lock);
-		return -ENODEV;
+		return ret;
 	}
 	if (attr == &attr_vol_reserved_ebs)
 		ret = sprintf(buf, "%d\n", vol->reserved_pebs);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] UBI: silence warning about possibly uninitialized use of variable in drivers/mtd/ubi/vmt.c ...
  2007-12-13 22:53 [PATCH] UBI: silence warning about possibly uninitialized use of variable in drivers/mtd/ubi/vmt.c Jesper Juhl
@ 2007-12-15 11:18 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2007-12-15 11:18 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-mtd, LKML

On Thu, 2007-12-13 at 23:53 +0100, Jesper Juhl wrote:
> From: Jesper Juhl <jesper.juhl@gmail.com>
> 
> This patch silences the following warning :
> 
>   drivers/mtd/ubi/vmt.c:73: warning: 'ret' may be used uninitialized in this function
> 
> gcc can't see that we always initialize ret in all situations where it is 
> actually used. The one case where it's not initialized is when we BUG(), 
> but gcc doesn't know that we won't then continue and use an uninitialized 
> 'ret'.
> 
> This patch results in code that does exactely the same as before, but it 
> also makes gcc shut up, so we generate one less line of warning noise.
> 
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

Pushed to ubi-2.6.git, thanks.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-15 11:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-13 22:53 [PATCH] UBI: silence warning about possibly uninitialized use of variable in drivers/mtd/ubi/vmt.c Jesper Juhl
2007-12-15 11:18 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).