From 890b1bf9bcbd90b70dbf7974948e135a14ee13b4 Mon Sep 17 00:00:00 2001
From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Fri, 17 Jan 2003 21:47:17 +0000
Subject: [PATCH] Fixed bug in smartctl pointed out by Gregory Goddard
 <ggoddard@ufl.edu>.  Manual says that bit 6 of return value turned on if
 errors found in smart error log.  But this wasn't implemented.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@455 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/CHANGELOG    |  9 ++++++++-
 sm5/VERSION      |  2 +-
 sm5/ataprint.c   | 13 +++++++------
 sm5/ataprint.cpp | 13 +++++++------
 sm5/ataprint.h   |  5 +++--
 5 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index fa9d22b7d..e7d28c92f 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.86 2003/01/14 20:04:03 ballen4705 Exp $
+$Id: CHANGELOG,v 1.87 2003/01/17 21:47:06 ballen4705 Exp $
 
 Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 
@@ -33,6 +33,13 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 CURRENT RELEASE (see VERSION file in this directory):
 
+  [BA] Fixed bug in smartctl pointed out by Gregory Goddard
+       <ggoddard@ufl.edu>.  Manual says that bit 6 of return
+       value turned on if errors found in smart error log.  But
+       this wasn't implemented.
+
+smartmontools-5.1-3
+
   [BA] Modified printing format for 9,minutes to read
        Xh+Ym not X h + Y m, so that fields are fixed width.
 
diff --git a/sm5/VERSION b/sm5/VERSION
index 00750edc0..b8626c4cf 100644
--- a/sm5/VERSION
+++ b/sm5/VERSION
@@ -1 +1 @@
-3
+4
diff --git a/sm5/ataprint.c b/sm5/ataprint.c
index 2a520d577..7b64d2044 100644
--- a/sm5/ataprint.c
+++ b/sm5/ataprint.c
@@ -31,7 +31,7 @@
 #include "extern.h"
 #include "utility.h"
 
-const char *ataprint_c_cvsid="$Id: ataprint.c,v 1.55 2003/01/16 15:28:57 ballen4705 Exp $"
+const char *ataprint_c_cvsid="$Id: ataprint.c,v 1.56 2003/01/17 21:47:12 ballen4705 Exp $"
 ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
 
 // for passing global control variables
@@ -506,7 +506,7 @@ int nonempty(unsigned char *testarea,int n){
 }
 
 // returns number of errors
-void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
+int ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
   int i,j,k;
   
   pout("SMART Error Log Version: %d\n", (int)data->revnumber);
@@ -514,7 +514,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
   // if no errors logged, return
   if (!data->error_log_pointer){
     pout("No Errors Logged\n\n");
-    return;
+    return 0;
   }
   QUIETON(con);
   // If log pointer out of range, return
@@ -522,7 +522,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
     pout("Invalid Error Log index = %02x (T13/1321D rev 1c"
 	 "Section 8.41.6.8.2.2 gives valid range from 1 to 5)\n\n",
 	 (int)data->error_log_pointer);
-    return;
+    return 0;
   }
 
   // Some internal consistency checking of the data structures
@@ -609,7 +609,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
   if (con->quietmode)
     pout("\n");
   QUIETOFF(con);
-  return;  
+  return data->ata_error_count;  
 }
 
 // return value is number of entries found where the self-test showed an error
@@ -972,7 +972,8 @@ int ataPrintMain (int fd){
     }
     else {
       // quiet mode is turned on inside ataPrintSmartErrorLog()
-      ataPrintSmartErrorlog(&smarterror);
+      if (ataPrintSmartErrorlog(&smarterror))
+	returnval|=FAILERR;
       QUIETOFF(con);
     }
   }
diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp
index 34f3f13d7..dcaa00257 100644
--- a/sm5/ataprint.cpp
+++ b/sm5/ataprint.cpp
@@ -31,7 +31,7 @@
 #include "extern.h"
 #include "utility.h"
 
-const char *ataprint_c_cvsid="$Id: ataprint.cpp,v 1.55 2003/01/16 15:28:57 ballen4705 Exp $"
+const char *ataprint_c_cvsid="$Id: ataprint.cpp,v 1.56 2003/01/17 21:47:12 ballen4705 Exp $"
 ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
 
 // for passing global control variables
@@ -506,7 +506,7 @@ int nonempty(unsigned char *testarea,int n){
 }
 
 // returns number of errors
-void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
+int ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
   int i,j,k;
   
   pout("SMART Error Log Version: %d\n", (int)data->revnumber);
@@ -514,7 +514,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
   // if no errors logged, return
   if (!data->error_log_pointer){
     pout("No Errors Logged\n\n");
-    return;
+    return 0;
   }
   QUIETON(con);
   // If log pointer out of range, return
@@ -522,7 +522,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
     pout("Invalid Error Log index = %02x (T13/1321D rev 1c"
 	 "Section 8.41.6.8.2.2 gives valid range from 1 to 5)\n\n",
 	 (int)data->error_log_pointer);
-    return;
+    return 0;
   }
 
   // Some internal consistency checking of the data structures
@@ -609,7 +609,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
   if (con->quietmode)
     pout("\n");
   QUIETOFF(con);
-  return;  
+  return data->ata_error_count;  
 }
 
 // return value is number of entries found where the self-test showed an error
@@ -972,7 +972,8 @@ int ataPrintMain (int fd){
     }
     else {
       // quiet mode is turned on inside ataPrintSmartErrorLog()
-      ataPrintSmartErrorlog(&smarterror);
+      if (ataPrintSmartErrorlog(&smarterror))
+	returnval|=FAILERR;
       QUIETOFF(con);
     }
   }
diff --git a/sm5/ataprint.h b/sm5/ataprint.h
index 309b2db6a..42db7d441 100644
--- a/sm5/ataprint.h
+++ b/sm5/ataprint.h
@@ -26,7 +26,7 @@
 #define _SMART_PRINT_H_
 
 #ifndef ATAPRINT_H_CVSID
-#define ATAPRINT_H_CVSID "$Id: ataprint.h,v 1.15 2003/01/16 15:28:57 ballen4705 Exp $\n"
+#define ATAPRINT_H_CVSID "$Id: ataprint.h,v 1.16 2003/01/17 21:47:17 ballen4705 Exp $\n"
 #endif
 
 #include <stdio.h>
@@ -46,7 +46,8 @@ void ataPrintGeneralSmartValues(struct ata_smart_values *);
 
 void ataPrintSmartThresholds(struct ata_smart_thresholds *);
 
-void ataPrintSmartErrorlog(struct ata_smart_errorlog *);
+// returns number of errors in Errorlog
+int  ataPrintSmartErrorlog(struct ata_smart_errorlog *);
 
 void PrintSmartAttributes(struct ata_smart_values *data);
 
-- 
GitLab