From c0246520a0d18f8ac41cd8c16de6449f2e1f6ec8 Mon Sep 17 00:00:00 2001
From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Mon, 15 Aug 2022 17:04:15 +0000
Subject: [PATCH] ataprint.cpp: Print error count even if error log index is
 invalid.

git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk@5407 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 smartmontools/ChangeLog    | 4 ++++
 smartmontools/ataprint.cpp | 7 ++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog
index fe8c089cb..6cdef5b7a 100644
--- a/smartmontools/ChangeLog
+++ b/smartmontools/ChangeLog
@@ -1,5 +1,9 @@
 $Id$
 
+2022-08-15  Christian Franke  <franke@computer.org>
+
+	ataprint.cpp: Print error count even if error log index is invalid.
+
 2022-08-07  Christian Franke  <franke@computer.org>
 
 	drivedb.h:
diff --git a/smartmontools/ataprint.cpp b/smartmontools/ataprint.cpp
index d3d480974..216b08909 100644
--- a/smartmontools/ataprint.cpp
+++ b/smartmontools/ataprint.cpp
@@ -2194,9 +2194,9 @@ static int PrintSmartErrorlog(const ata_smart_errorlog *data,
   print_on();
   // If log pointer out of range, return
   if (data->error_log_pointer>5){
-    pout("Invalid Error Log index = 0x%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);
+    pout("Invalid Error Log index = 0x%02x (valid range is from 1 to 5)\n",
+         data->error_log_pointer);
+    pout("ATA Error Count: %d (possibly also invalid)\n\n", data->ata_error_count);
     return 0;
   }
 
@@ -2359,6 +2359,7 @@ static int PrintSmartExtErrorLog(ata_device * device,
     // to 0.
     if (!(erridx == 0 && 1 <= log->reserved1 && log->reserved1 <= nentries)) {
       pout("Invalid Error Log index = 0x%04x (reserved = 0x%02x)\n", erridx, log->reserved1);
+      pout("Device Error Count: %d (possibly also invalid)\n\n", log->device_error_count);
       return 0;
     }
     pout("Invalid Error Log index = 0x%04x, trying reserved byte (0x%02x) instead\n", erridx, log->reserved1);
-- 
GitLab