From cde869427cbd3238f1b5722357c0084e439a7d2e Mon Sep 17 00:00:00 2001
From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Thu, 14 Nov 2002 14:57:20 +0000
Subject: [PATCH] Changed numbering of entries in ATA error log printout to
 make it clearer which is the most recent and which is the oldest.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@276 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/VERSION      |  2 +-
 sm5/ataprint.c   | 14 ++++++++++----
 sm5/ataprint.cpp | 14 ++++++++++----
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/sm5/VERSION b/sm5/VERSION
index 920a13966..c739b42c4 100644
--- a/sm5/VERSION
+++ b/sm5/VERSION
@@ -1 +1 @@
-43
+44
diff --git a/sm5/ataprint.c b/sm5/ataprint.c
index 7ff6c631b..5a2fb37ad 100644
--- a/sm5/ataprint.c
+++ b/sm5/ataprint.c
@@ -30,7 +30,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid2="$Id: ataprint.c,v 1.43 2002/11/07 19:07:20 ballen4705 Exp $"
+const char *CVSid2="$Id: ataprint.c,v 1.44 2002/11/14 14:57:20 ballen4705 Exp $"
 CVSID1 CVSID2 CVSID3 CVSID6;
 
 // for passing global control variables
@@ -505,13 +505,19 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
     return;
   }
   QUIETON(con);
-  // if log pointer out of range, return
-  if ( data->error_log_pointer>5 ){
+  // If log pointer out of range, return
+  if (data->error_log_pointer>5){
     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;
   }
+
+  // Some internal consistency checking of the data structures
+  if ((data->ata_error_count-data->error_log_pointer)%5) {
+    pout("Warning: ATA error count %d inconsistent with error log pointer %d\n\n",
+	 data->ata_error_count,data->error_log_pointer);
+  }
   
   // starting printing error log info
   if (data->ata_error_count<=5)
@@ -553,7 +559,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
       // See table 42 of ATA5 spec
       QUIETON(con);
       pout("Error %d occurred at disk power-on lifetime: %d hours\n",
-	     (int)(5-k), (int)data->errorlog_struct[i].error_struct.timestamp);
+	     (int)(data->ata_error_count+k-4), (int)data->errorlog_struct[i].error_struct.timestamp);
       QUIETOFF(con);
       pout("When the command that caused the error occurred, the device was %s.\n",msgstate);
       pout("After command completion occurred, registers were:\n");
diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp
index a83265312..eac4d660d 100644
--- a/sm5/ataprint.cpp
+++ b/sm5/ataprint.cpp
@@ -30,7 +30,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid2="$Id: ataprint.cpp,v 1.43 2002/11/07 19:07:20 ballen4705 Exp $"
+const char *CVSid2="$Id: ataprint.cpp,v 1.44 2002/11/14 14:57:20 ballen4705 Exp $"
 CVSID1 CVSID2 CVSID3 CVSID6;
 
 // for passing global control variables
@@ -505,13 +505,19 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
     return;
   }
   QUIETON(con);
-  // if log pointer out of range, return
-  if ( data->error_log_pointer>5 ){
+  // If log pointer out of range, return
+  if (data->error_log_pointer>5){
     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;
   }
+
+  // Some internal consistency checking of the data structures
+  if ((data->ata_error_count-data->error_log_pointer)%5) {
+    pout("Warning: ATA error count %d inconsistent with error log pointer %d\n\n",
+	 data->ata_error_count,data->error_log_pointer);
+  }
   
   // starting printing error log info
   if (data->ata_error_count<=5)
@@ -553,7 +559,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog *data){
       // See table 42 of ATA5 spec
       QUIETON(con);
       pout("Error %d occurred at disk power-on lifetime: %d hours\n",
-	     (int)(5-k), (int)data->errorlog_struct[i].error_struct.timestamp);
+	     (int)(data->ata_error_count+k-4), (int)data->errorlog_struct[i].error_struct.timestamp);
       QUIETOFF(con);
       pout("When the command that caused the error occurred, the device was %s.\n",msgstate);
       pout("After command completion occurred, registers were:\n");
-- 
GitLab