libatasmart-uninitialized-var.patch 1.4 KB

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