libatasmart/libatasmart-uninitialized-var.patch

53 lines
1.5 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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