Diff for /embedaddon/smartmontools/knowndrives.cpp between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 16:32:16 version 1.1.1.2, 2013/07/22 01:17:35
Line 5 Line 5
  * Address of support mailing list: smartmontools-support@lists.sourceforge.net   * Address of support mailing list: smartmontools-support@lists.sourceforge.net
  *   *
  * Copyright (C) 2003-11 Philip Williams, Bruce Allen   * Copyright (C) 2003-11 Philip Williams, Bruce Allen
 * Copyright (C) 2008-11 Christian Franke <smartmontools-support@lists.sourceforge.net> * Copyright (C) 2008-12 Christian Franke <smartmontools-support@lists.sourceforge.net>
  *   *
  * This program is free software; you can redistribute it and/or modify   * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
Line 13 Line 13
  * any later version.   * any later version.
  *   *
  * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
 * (for example COPYING); if not, write to the Free * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  *   *
  */   */
   
Line 124  void drive_database::push_back(const drive_settings &  Line 123  void drive_database::push_back(const drive_settings & 
   
 const char * drive_database::copy_string(const char * src)  const char * drive_database::copy_string(const char * src)
 {  {
  char * dest = new char[strlen(src)+1];  size_t len = strlen(src);
   char * dest = new char[len+1];
   memcpy(dest, src, len+1);
   try {    try {
     m_custom_strings.push_back(dest);      m_custom_strings.push_back(dest);
   }    }
   catch (...) {    catch (...) {
     delete [] dest; throw;      delete [] dest; throw;
   }    }
  return strcpy(dest, src);  return dest;
 }  }
   
   
Line 208  static const drive_settings * lookup_drive(const char  Line 209  static const drive_settings * lookup_drive(const char 
   
 // Parse drive or USB options in preset string, return false on error.  // Parse drive or USB options in preset string, return false on error.
 static bool parse_db_presets(const char * presets, ata_vendor_attr_defs * defs,  static bool parse_db_presets(const char * presets, ata_vendor_attr_defs * defs,
                             unsigned char * fix_firmwarebug, std::string * type)                             firmwarebug_defs * firmwarebugs, std::string * type)
 {  {
   for (int i = 0; ; ) {    for (int i = 0; ; ) {
     i += strspn(presets+i, " \t");      i += strspn(presets+i, " \t");
Line 222  static bool parse_db_presets(const char * presets, ata Line 223  static bool parse_db_presets(const char * presets, ata
       if (!parse_attribute_def(arg, *defs, PRIOR_DATABASE))        if (!parse_attribute_def(arg, *defs, PRIOR_DATABASE))
         return false;          return false;
     }      }
    else if (opt == 'F' && fix_firmwarebug) {    else if (opt == 'F' && firmwarebugs) {
      unsigned char fix;      firmwarebug_defs bug;
      if (!strcmp(arg, "samsung"))      if (!parse_firmwarebug_def(arg, bug))
        fix = FIX_SAMSUNG; 
      else if (!strcmp(arg, "samsung2")) 
        fix = FIX_SAMSUNG2; 
      else if (!strcmp(arg, "samsung3")) 
        fix = FIX_SAMSUNG3; 
      else 
         return false;          return false;
      // Set only if not set by user      // Don't set if user specified '-F none'.
      if (*fix_firmwarebug == FIX_NOTSPECIFIED)      if (!firmwarebugs->is_set(BUG_NONE))
        *fix_firmwarebug = fix;        firmwarebugs->set(bug);
     }      }
     else if (opt == 'd' && type) {      else if (opt == 'd' && type) {
         // TODO: Check valid types          // TODO: Check valid types
Line 251  static bool parse_db_presets(const char * presets, ata Line 246  static bool parse_db_presets(const char * presets, ata
 // Parse '-v' and '-F' options in preset string, return false on error.  // Parse '-v' and '-F' options in preset string, return false on error.
 static inline bool parse_presets(const char * presets,  static inline bool parse_presets(const char * presets,
                                  ata_vendor_attr_defs & defs,                                   ata_vendor_attr_defs & defs,
                                 unsigned char & fix_firmwarebug)                                 firmwarebug_defs & firmwarebugs)
 {  {
  return parse_db_presets(presets, &defs, &fix_firmwarebug, 0);  return parse_db_presets(presets, &defs, &firmwarebugs, 0);
 }  }
   
 // Parse '-d' option in preset string, return false on error.  // Parse '-d' option in preset string, return false on error.
Line 365  static int showonepreset(const drive_settings * dbentr Line 360  static int showonepreset(const drive_settings * dbentr
     pout("%-*s %s\n", TABLEPRINTWIDTH, "MODEL FAMILY:", dbentry->modelfamily);      pout("%-*s %s\n", TABLEPRINTWIDTH, "MODEL FAMILY:", dbentry->modelfamily);
   
     // if there are any presets, then show them      // if there are any presets, then show them
    unsigned char fix_firmwarebug = 0;    firmwarebug_defs firmwarebugs;
     bool first_preset = true;      bool first_preset = true;
     if (*dbentry->presets) {      if (*dbentry->presets) {
       ata_vendor_attr_defs defs;        ata_vendor_attr_defs defs;
      if (!parse_presets(dbentry->presets, defs, fix_firmwarebug)) {      if (!parse_presets(dbentry->presets, defs, firmwarebugs)) {
         pout("Syntax error in preset option string \"%s\"\n", dbentry->presets);          pout("Syntax error in preset option string \"%s\"\n", dbentry->presets);
         errcnt++;          errcnt++;
       }        }
Line 393  static int showonepreset(const drive_settings * dbentr Line 388  static int showonepreset(const drive_settings * dbentr
       pout("%-*s %s\n", TABLEPRINTWIDTH, "ATTRIBUTE OPTIONS:", "None preset; no -v options are required.");        pout("%-*s %s\n", TABLEPRINTWIDTH, "ATTRIBUTE OPTIONS:", "None preset; no -v options are required.");
   
     // describe firmwarefix      // describe firmwarefix
    if (fix_firmwarebug) {    for (int b = BUG_NOLOGDIR; b <= BUG_XERRORLBA; b++) {
       if (!firmwarebugs.is_set((firmwarebug_t)b))
         continue;
       const char * fixdesc;        const char * fixdesc;
      switch (fix_firmwarebug) {      switch ((firmwarebug_t)b) {
        case FIX_SAMSUNG:        case BUG_NOLOGDIR:
           fixdesc = "Avoids reading GP/SMART Log Directories (same as -F nologdir)";
           break;
         case BUG_SAMSUNG:
           fixdesc = "Fixes byte order in some SMART data (same as -F samsung)";            fixdesc = "Fixes byte order in some SMART data (same as -F samsung)";
           break;            break;
        case FIX_SAMSUNG2:        case BUG_SAMSUNG2:
           fixdesc = "Fixes byte order in some SMART data (same as -F samsung2)";            fixdesc = "Fixes byte order in some SMART data (same as -F samsung2)";
           break;            break;
        case FIX_SAMSUNG3:        case BUG_SAMSUNG3:
           fixdesc = "Fixes completed self-test reported as in progress (same as -F samsung3)";            fixdesc = "Fixes completed self-test reported as in progress (same as -F samsung3)";
           break;            break;
           case BUG_XERRORLBA:
             fixdesc = "Fixes LBA byte ordering in Ext. Comprehensive SMART error log (same as -F xerrorlba)";
             break;
         default:          default:
           fixdesc = "UNKNOWN"; errcnt++;            fixdesc = "UNKNOWN"; errcnt++;
           break;            break;
Line 525  void show_presets(const ata_identify_device * drive) Line 528  void show_presets(const ata_identify_device * drive)
 }  }
   
 // Searches drive database and sets preset vendor attribute  // Searches drive database and sets preset vendor attribute
// options in defs and fix_firmwarebug.// options in defs and firmwarebugs.
 // Values that have already been set will not be changed.  // Values that have already been set will not be changed.
 // Returns pointer to database entry or nullptr if none found  // Returns pointer to database entry or nullptr if none found
 const drive_settings * lookup_drive_apply_presets(  const drive_settings * lookup_drive_apply_presets(
   const ata_identify_device * drive, ata_vendor_attr_defs & defs,    const ata_identify_device * drive, ata_vendor_attr_defs & defs,
  unsigned char & fix_firmwarebug)  firmwarebug_defs & firmwarebugs)
 {  {
   // get the drive's model/firmware strings    // get the drive's model/firmware strings
   char model[MODEL_STRING_LENGTH+1], firmware[FIRMWARE_STRING_LENGTH+1];    char model[MODEL_STRING_LENGTH+1], firmware[FIRMWARE_STRING_LENGTH+1];
Line 544  const drive_settings * lookup_drive_apply_presets( Line 547  const drive_settings * lookup_drive_apply_presets(
   
   if (*dbentry->presets) {    if (*dbentry->presets) {
     // Apply presets      // Apply presets
    if (!parse_presets(dbentry->presets, defs, fix_firmwarebug))    if (!parse_presets(dbentry->presets, defs, firmwarebugs))
       pout("Syntax error in preset option string \"%s\"\n", dbentry->presets);        pout("Syntax error in preset option string \"%s\"\n", dbentry->presets);
   }    }
   return dbentry;    return dbentry;
Line 765  static bool parse_drive_database(parse_ptr src, drive_ Line 768  static bool parse_drive_database(parse_ptr src, drive_
           case 4:            case 4:
             if (!token.value.empty()) {              if (!token.value.empty()) {
               if (!is_usb_modelfamily(values[0].c_str())) {                if (!is_usb_modelfamily(values[0].c_str())) {
                ata_vendor_attr_defs defs; unsigned char fix = 0;                ata_vendor_attr_defs defs; firmwarebug_defs fix;
                 if (!parse_presets(token.value.c_str(), defs, fix)) {                  if (!parse_presets(token.value.c_str(), defs, fix)) {
                   pout("%s(%d): Syntax error in preset option string\n", path, token.line);                    pout("%s(%d): Syntax error in preset option string\n", path, token.line);
                   ok = false;                    ok = false;

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>