From 90aca90bce6b8f56fcf6b39188a03e5d5754aea7 Mon Sep 17 00:00:00 2001
From: manfred99 <manfred99@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Mon, 26 Oct 2009 22:26:05 +0000
Subject: [PATCH] attribute update: trim attribute names to 23 chars

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2972 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 smartmontools/CHANGELOG   | 3 +++
 smartmontools/atacmds.cpp | 8 +++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG
index a3e694c15..d863e5b65 100644
--- a/smartmontools/CHANGELOG
+++ b/smartmontools/CHANGELOG
@@ -43,6 +43,9 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [MS] attribute update:
+       trim attribute names to 23 chars
+
   [CF] Add smart pointer class template to manage device object pointers.
        Remove related 'delete' calls and 'try/catch' blocks.
 
diff --git a/smartmontools/atacmds.cpp b/smartmontools/atacmds.cpp
index 13755f988..09d843a6b 100644
--- a/smartmontools/atacmds.cpp
+++ b/smartmontools/atacmds.cpp
@@ -1920,6 +1920,8 @@ int64_t ataPrintSmartAttribRawValue(char *out,
 // manufacturers use different attribute IDs for an attribute with the
 // same name.  The variable val should contain a non-zero value if a particular
 // attributes has a non-default interpretation.
+// Attribute names shouldn't be longer than 23 chars, otherwise they break the
+// output of smartctl.
 void ataPrintSmartAttribName(char * out, unsigned char id, const unsigned char * definitions){
   const char *name;
   unsigned char val;
@@ -2043,7 +2045,7 @@ void ataPrintSmartAttribName(char * out, unsigned char id, const unsigned char *
     switch (val) {
     case 1:
       // Fujitsu
-      name="Emergency_Retract_Cycle_Ct";
+      name="Emerg_Retract_Cycle_Ct";
       break;
     default:
       name="Power-Off_Retract_Count";
@@ -2097,7 +2099,7 @@ void ataPrintSmartAttribName(char * out, unsigned char id, const unsigned char *
       break;
     case 2:
       // Fujitsu
-      name="Off-line_Scan_UNC_Sector_Ct";
+      name="Offline_Scan_UNC_SectCt";
       break;
     }
     break;
@@ -2211,7 +2213,7 @@ void ataPrintSmartAttribName(char * out, unsigned char id, const unsigned char *
     break;
   case 232:
     // seen in Intel X25-E SSD
-    name="Available_Reserved_Space";
+    name="Available_Reservd_Space";
     break;
   case 233:
     // seen in Intel X25-E SSD
-- 
GitLab