]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - knowndrives.cpp
Imported Upstream version 5.42+svn3539
[mirror_smartmontools-debian.git] / knowndrives.cpp
index 1f2e73470de6889b53fcc4ef6a200315861a1bb4..422b8654eebb499117fc3ab0ded0a840f3c183f9 100644 (file)
@@ -34,7 +34,7 @@
 
 #include <stdexcept>
 
-const char * knowndrives_cpp_cvsid = "$Id: knowndrives.cpp 3289 2011-03-09 19:52:04Z chrfranke $"
+const char * knowndrives_cpp_cvsid = "$Id: knowndrives.cpp 3447 2011-10-14 20:32:00Z chrfranke $"
                                      KNOWNDRIVES_H_CVSID;
 
 #define MODEL_STRING_LENGTH                         40
@@ -214,8 +214,8 @@ static bool parse_db_presets(const char * presets, ata_vendor_attr_defs * defs,
     i += strspn(presets+i, " \t");
     if (!presets[i])
       break;
-    char opt, arg[40+1+13]; int len = -1;
-    if (!(sscanf(presets+i, "-%c %40[^ ]%n", &opt, arg, &len) >= 2 && len > 0))
+    char opt, arg[80+1+13]; int len = -1;
+    if (!(sscanf(presets+i, "-%c %80[^ ]%n", &opt, arg, &len) >= 2 && len > 0))
       return false;
     if (opt == 'v' && defs) {
       // Parse "-v N,format[,name]"
@@ -375,9 +375,16 @@ static int showonepreset(const drive_settings * dbentry)
       }
       for (int i = 0; i < MAX_ATTRIBUTE_NUM; i++) {
         if (defs[i].priority != PRIOR_DEFAULT) {
+          std::string name = ata_get_smart_attr_name(i, defs);
           // Use leading zeros instead of spaces so that everything lines up.
           pout("%-*s %03d %s\n", TABLEPRINTWIDTH, first_preset ? "ATTRIBUTE OPTIONS:" : "",
-               i, ata_get_smart_attr_name(i, defs).c_str());
+               i, name.c_str());
+          // Check max name length suitable for smartctl -A output
+          const unsigned maxlen = 23;
+          if (name.size() > maxlen) {
+            pout("%*s\n", TABLEPRINTWIDTH+6+maxlen, "Error: Attribute name too long ------^");
+            errcnt++;
+          }
           first_preset = false;
         }
       }