404be79
From 26f0cc57fcf346753f17e75fb1378f053dcba92c Mon Sep 17 00:00:00 2001
404be79
From: David Zeuthen <davidz@redhat.com>
404be79
Date: Wed, 9 Dec 2009 17:14:36 -0500
404be79
Subject: [PATCH] fix return of uninitialized variable
404be79
MIME-Version: 1.0
404be79
Content-Type: text/plain; charset=UTF-8
404be79
Content-Transfer-Encoding: 8bit
404be79
404be79
 atasmart.c: In function ‘init_smart’:
404be79
 atasmart.c:2556: warning: ‘ret’ may be used uninitialized in this function
404be79
404be79
We apparently don't initialize the ret variable in init_smart() -
404be79
unfortunately
404be79
404be79
 o  this warning is never reported with using -O0 (thanks gcc -
404be79
    see http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings though)
404be79
404be79
 o  we never run into this bug with just skdump(1)
404be79
404be79
The bug does show up in the udisks (aka DeviceKit-disks) use of
404be79
libatasmart and this patch fixes it.
404be79
404be79
Signed-off-by: David Zeuthen <davidz@redhat.com>
404be79
---
404be79
 atasmart.c |    4 ++++
404be79
 1 files changed, 4 insertions(+), 0 deletions(-)
404be79
404be79
diff --git a/atasmart.c b/atasmart.c
404be79
index 3ff0334..cf93819 100644
404be79
--- a/atasmart.c
404be79
+++ b/atasmart.c
404be79
@@ -2564,6 +2564,8 @@ static int init_smart(SkDisk *d) {
404be79
         if (!disk_smart_is_available(d))
404be79
                 return 0;
404be79
 
404be79
+        ret = -1;
404be79
+
404be79
         if (!disk_smart_is_enabled(d)) {
404be79
                 if ((ret = disk_smart_enable(d, TRUE)) < 0)
404be79
                         goto fail;
404be79
@@ -2580,6 +2582,8 @@ static int init_smart(SkDisk *d) {
404be79
 
404be79
         disk_smart_read_thresholds(d);
404be79
 
404be79
+        ret = 0;
404be79
+
404be79
 fail:
404be79
         return ret;
404be79
 }
404be79
-- 
404be79
1.6.5.5
404be79