diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index af31b018ae9404ff148b711b4174ac3306381cf3..8800133fa7aa9cd34216ec156841c2f21d460d00 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 9d5777bcca42a4f083717ca3a6cff10731d06664..88137c4a15c7cbb26fd4c586527f8b69b6223aee 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;