From 4e2dee85c7b630f3d82aed6fca3af4b669ef2844 Mon Sep 17 00:00:00 2001
From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Thu, 29 Jan 2009 20:29:00 +0000
Subject: [PATCH] Minor fix to remove ID 0 from 'smartctl -l sataphy ...'
 output.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2719 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/CHANGELOG    |  4 +++-
 sm5/ataprint.cpp | 12 +++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index af31b018a..8800133fa 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.766 2009/01/27 21:12:00 chrfranke Exp $
+$Id: CHANGELOG,v 1.767 2009/01/29 20:29:00 chrfranke Exp $
 
 The most recent version of this file is:
 http://smartmontools.cvs.sourceforge.net/smartmontools/sm5/CHANGELOG?view=markup
@@ -41,6 +41,8 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [CF] Minor fix to remove ID 0 from 'smartctl -l sataphy ...' output.
+
   [CF] knowndrives.cpp updates: Add warnings about possible firmware
        bugs to Seagate 7200.11, ES.2 and DiamondMax 22 entries.
 
diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp
index 9d5777bcc..88137c4a1 100644
--- a/sm5/ataprint.cpp
+++ b/sm5/ataprint.cpp
@@ -43,7 +43,7 @@
 #include "utility.h"
 #include "knowndrives.h"
 
-const char *ataprint_c_cvsid="$Id: ataprint.cpp,v 1.204 2009/01/15 22:52:50 chrfranke Exp $"
+const char *ataprint_c_cvsid="$Id: ataprint.cpp,v 1.205 2009/01/29 20:29:00 chrfranke Exp $"
 ATACMDNAMES_H_CVSID ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
 
 // for passing global control variables
@@ -971,16 +971,18 @@ static void PrintSataPhyEventCounters(const unsigned char * data, bool reset)
     pout("[Reserved: 0x%02x 0x%02x 0x%02x 0x%02x]\n",
     data[0], data[1], data[2], data[3]);
   pout("ID      Size     Value  Description\n");
+
   for (unsigned i = 4; ; ) {
-    // Get counter id
+    // Get counter id and size (bits 14:12)
     unsigned id = data[i] | (data[i+1] << 8);
+    unsigned size = ((id >> 12) & 0x7) << 1;
+    id &= 0x8fff;
+
+    // End of counter table ?
     if (!id)
       break;
     i += 2;
 
-    // Get counter size (bits 14:12)
-    unsigned size = ((id >> 12) & 0x7) << 1;
-    id &= 0x8fff;
     if (!(2 <= size && size <= 8 && i + size < 512)) {
       pout("0x%04x  %u: Invalid entry\n", id, size);
       break;
-- 
GitLab