diff --git a/sm5/VERSION b/sm5/VERSION
index aabe6ec3909c9d4871f8f89ef88ca3b6795ebd29..2bd5a0a98a36cc08ada88b804d3be047e6aa5b8a 100644
--- a/sm5/VERSION
+++ b/sm5/VERSION
@@ -1 +1 @@
-21
+22
diff --git a/sm5/atacmds.c b/sm5/atacmds.c
index e45a90be948b28c8179763d681c12b5dfd700bc1..2eeb563f63d8a1e8a73c25767a68188fd25bc5c2 100644
--- a/sm5/atacmds.c
+++ b/sm5/atacmds.c
@@ -30,7 +30,7 @@
 #include <stdlib.h>
 #include "atacmds.h"
 
-const char *CVSid1="$Id: atacmds.c,v 1.32 2002/10/29 18:19:02 ballen4705 Exp $" CVSID1;
+const char *CVSid1="$Id: atacmds.c,v 1.33 2002/10/29 23:09:28 ballen4705 Exp $" CVSID1;
 
 // These Drive Identity tables are taken from hdparm 5.2, and are also
 // given in the ATA/ATAPI specs for the IDENTIFY DEVICE command.  Note
@@ -806,7 +806,7 @@ void ataPrintSmartAttribName(char *out, unsigned char id){
     name="Unknown_Attribute";
     break;
   }
-  sprintf(out,"%3d %s",id,name);
+  sprintf(out,"%3hhu %s",id,name);
   return;
 }
 
diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp
index 3b156ca7235c4c393c7492592d4cf7b7f64b7e4d..8d6398b8bfa0c1fa2d6ac5726f9a216808c21ee5 100644
--- a/sm5/atacmds.cpp
+++ b/sm5/atacmds.cpp
@@ -30,7 +30,7 @@
 #include <stdlib.h>
 #include "atacmds.h"
 
-const char *CVSid1="$Id: atacmds.cpp,v 1.32 2002/10/29 18:19:02 ballen4705 Exp $" CVSID1;
+const char *CVSid1="$Id: atacmds.cpp,v 1.33 2002/10/29 23:09:28 ballen4705 Exp $" CVSID1;
 
 // These Drive Identity tables are taken from hdparm 5.2, and are also
 // given in the ATA/ATAPI specs for the IDENTIFY DEVICE command.  Note
@@ -806,7 +806,7 @@ void ataPrintSmartAttribName(char *out, unsigned char id){
     name="Unknown_Attribute";
     break;
   }
-  sprintf(out,"%3d %s",id,name);
+  sprintf(out,"%3hhu %s",id,name);
   return;
 }
 
diff --git a/sm5/atacmds.h b/sm5/atacmds.h
index 6285b6d2bb32d6ab590ce6f153e115d972952aab..d3df6b93d2f7e81b1162571011717ac8cb9ca0d8 100644
--- a/sm5/atacmds.h
+++ b/sm5/atacmds.h
@@ -26,7 +26,7 @@
 #define _ATACMDS_H_
 
 #ifndef CVSID1
-#define CVSID1 "$Id: atacmds.h,v 1.21 2002/10/28 23:46:59 ballen4705 Exp $\n"
+#define CVSID1 "$Id: atacmds.h,v 1.22 2002/10/29 23:09:28 ballen4705 Exp $\n"
 #endif
 
 // These are the major and minor versions for smartd and smartctl
@@ -117,16 +117,6 @@
 #define HDIO_DRIVE_TASK_HDR_SIZE	7
 #endif
 
-
-
-
-/* Smart Values Data Structures */
-
-/* Smart Status Flags */
-
-
-
-
 /* ata_smart_attribute is the vendor specific in SFF-8035 spec */ 
 struct ata_smart_attribute {
   unsigned char id;
@@ -136,7 +126,7 @@ struct ata_smart_attribute {
       unsigned prefailure:1;   // 0=> low attribute from age/usage
 			       // exceeding design limit,
 			       // 1==prefailure
-
+      
       unsigned online:1;       // 0==> attribute only updated during
 			       // off-line testing. 1==>only updated
 			       // during on-line testing
@@ -230,21 +220,21 @@ struct ata_smart_errorlog_error_struct {
 
 // Table 41 of T13/1321D Rev 1 spec (Command Data Structure)
 struct ata_smart_errorlog_command_struct {
-	unsigned char devicecontrolreg;
-	unsigned char featuresreg;
-	unsigned char sector_count;
-	unsigned char sector_number;
-	unsigned char cylinder_low;
-	unsigned char cylinder_high;
-	unsigned char drive_head;
-	unsigned char commandreg;
-	unsigned int timestamp;
+  unsigned char devicecontrolreg;
+  unsigned char featuresreg;
+  unsigned char sector_count;
+  unsigned char sector_number;
+  unsigned char cylinder_low;
+  unsigned char cylinder_high;
+  unsigned char drive_head;
+  unsigned char commandreg;
+  unsigned int timestamp;
 } __attribute__ ((packed));
 
 // Table 40 of T13/1321D Rev 1 spec (Error log data structure)
 struct ata_smart_errorlog_struct {
-	struct ata_smart_errorlog_command_struct commands[5];
-	struct ata_smart_errorlog_error_struct error_struct;
+  struct ata_smart_errorlog_command_struct commands[5];
+  struct ata_smart_errorlog_error_struct error_struct;
 }  __attribute__ ((packed));
 
 // Table 39 of T13/1321D Rev 1 spec (SMART error log sector)
@@ -260,26 +250,24 @@ struct ata_smart_errorlog {
 // Table 45 of T13/1321D Rev 1 spec (Self-test log descriptor entry)
 struct ata_smart_selftestlog_struct {
   unsigned char selftestnumber; // Sector number register
-	unsigned char selfteststatus;
-	unsigned short int timestamp;
-	unsigned char selftestfailurecheckpoint;
-	unsigned int lbafirstfailure;
-	unsigned char vendorspecific[15];
+  unsigned char selfteststatus;
+  unsigned short int timestamp;
+  unsigned char selftestfailurecheckpoint;
+  unsigned int lbafirstfailure;
+  unsigned char vendorspecific[15];
 } __attribute__ ((packed));
 
 // Table 44 of T13/1321D Rev 1 spec (Self-test log data structure)
 struct ata_smart_selftestlog {
-	unsigned short int revnumber;
-	struct ata_smart_selftestlog_struct selftest_struct[21];
-	unsigned char vendorspecific[2];
-	unsigned char mostrecenttest;
-	unsigned char reserved[2];
-	unsigned char chksum;
+  unsigned short int revnumber;
+  struct ata_smart_selftestlog_struct selftest_struct[21];
+  unsigned char vendorspecific[2];
+  unsigned char mostrecenttest;
+  unsigned char reserved[2];
+  unsigned char chksum;
 } __attribute__ ((packed));
 
  
-
-
 /* Read S.M.A.R.T information from drive */
 int ataReadHDIdentity (int device, struct hd_driveid *buf);
 int ataReadSmartValues (int device,struct ata_smart_values *);
@@ -299,7 +287,6 @@ int ataDisableAutoSave(int device);
 int ataEnableAutoOffline ( int device );
 int ataDisableAutoOffline (int device );
 
-
 /* S.M.A.R.T. test commands */
 int ataSmartOfflineTest (int device);
 int ataSmartExtendSelfTest (int device);
@@ -308,15 +295,10 @@ int ataSmartShortCapSelfTest (int device);
 int ataSmartExtendCapSelfTest (int device);
 int ataSmartSelfTestAbort (int device);
 
-/*Check Parameters of Smart Data */
-
-
-
 // Returns the latest compatibility of ATA/ATAPI Version the device
 // supports. Returns -1 if Version command is not supported
 int ataVersionInfo (const char **description, struct hd_driveid drive, unsigned short *minor);
 
-
 // If SMART supported, this is guaranteed to return 1 if SMART is enabled, else 0.
 int ataDoesSmartWork(int device);
 
@@ -336,39 +318,26 @@ int ataCheckSmart ( struct ata_smart_values data, struct ata_smart_thresholds th
 
 int ataSmartStatus2(int device);
 
-
-
-/* int isOfflineTestTime ( struct ata_smart_values data)
-*  returns S.M.A.R.T. Offline Test Time in seconds
-*/
-
+// int isOfflineTestTime ( struct ata_smart_values data)
+//  returns S.M.A.R.T. Offline Test Time in seconds
 int isOfflineTestTime ( struct ata_smart_values data);
 
 int isShortSelfTestTime ( struct ata_smart_values data);
 
 int isExtendedSelfTestTime ( struct ata_smart_values data);
 
-
-
-
 int isSmartErrorLogCapable ( struct ata_smart_values data);
 
-
 int isSupportExecuteOfflineImmediate ( struct ata_smart_values data);
 
-
 int isSupportAutomaticTimer ( struct ata_smart_values data);
 
-
 int isSupportOfflineAbort ( struct ata_smart_values data);
 
-
 int isSupportOfflineSurfaceScan ( struct ata_smart_values data);
 
-
 int isSupportSelfTest (struct ata_smart_values data);
 
-
 int ataSmartTest(int device, int testtype);
 
 int TestTime(struct ata_smart_values data,int testtype);
diff --git a/sm5/ataprint.c b/sm5/ataprint.c
index 1ddf45baa1dd9bdb39958268b108e477a429336f..f882e2b9c32fee5c133f4cc9c0b2c7f82d8e6b6a 100644
--- a/sm5/ataprint.c
+++ b/sm5/ataprint.c
@@ -29,7 +29,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid2="$Id: ataprint.c,v 1.37 2002/10/29 22:09:52 ballen4705 Exp $"
+const char *CVSid2="$Id: ataprint.c,v 1.38 2002/10/29 23:09:28 ballen4705 Exp $"
 CVSID1 CVSID2 CVSID3 CVSID6;
 
 // for passing global control variables
@@ -168,64 +168,64 @@ void PrintSmartOfflineStatus(struct ata_smart_values data){
 
 void PrintSmartSelfExecStatus ( struct ata_smart_values data)
 {
-   pout ("Self-test execution status:      ");
+   pout("Self-test execution status:      ");
    
    switch (data.self_test_exec_status >> 4)
    {
       case 0:
-        pout ("(%4d)\tThe previous self-test routine completed\n\t\t\t\t\t",
+        pout("(%4d)\tThe previous self-test routine completed\n\t\t\t\t\t",
                 data.self_test_exec_status);
-        pout ("without error or no self-test has ever \n\t\t\t\t\tbeen run.\n");
+        pout("without error or no self-test has ever \n\t\t\t\t\tbeen run.\n");
         break;
        case 1:
-         pout ("(%4d)\tThe self-test routine was aborted by\n\t\t\t\t\t",
+         pout("(%4d)\tThe self-test routine was aborted by\n\t\t\t\t\t",
                  data.self_test_exec_status);
-         pout ("the host.\n");
+         pout("the host.\n");
          break;
        case 2:
-         pout ("(%4d)\tThe self-test routine was interrupted\n\t\t\t\t\t",
+         pout("(%4d)\tThe self-test routine was interrupted\n\t\t\t\t\t",
                  data.self_test_exec_status);
-         pout ("by the host with a hard or soft reset.\n");
+         pout("by the host with a hard or soft reset.\n");
          break;
        case 3:
-          pout ("(%4d)\tA fatal error or unknown test error\n\t\t\t\t\t",
+          pout("(%4d)\tA fatal error or unknown test error\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("occurred while the device was executing\n\t\t\t\t\t");
-          pout ("its self-test routine and the device \n\t\t\t\t\t");
-          pout ("was unable to complete the self-test \n\t\t\t\t\t");
-          pout ("routine.\n");
+          pout("occurred while the device was executing\n\t\t\t\t\t");
+          pout("its self-test routine and the device \n\t\t\t\t\t");
+          pout("was unable to complete the self-test \n\t\t\t\t\t");
+          pout("routine.\n");
           break;
        case 4:
-          pout ("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
+          pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("a test element that failed and the test\n\t\t\t\t\t");
-          pout ("element that failed is not known.\n");
+          pout("a test element that failed and the test\n\t\t\t\t\t");
+          pout("element that failed is not known.\n");
           break;
        case 5:
-          pout ("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
+          pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("the electrical element of the test\n\t\t\t\t\t");
-          pout ("failed.\n");
+          pout("the electrical element of the test\n\t\t\t\t\t");
+          pout("failed.\n");
           break;
        case 6:
-          pout ("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
+          pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("the servo (and/or seek) element of the \n\t\t\t\t\t");
-          pout ("test failed.\n");
+          pout("the servo (and/or seek) element of the \n\t\t\t\t\t");
+          pout("test failed.\n");
           break;
        case 7:
-          pout ("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
+          pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("the read element of the test failed.\n");
+          pout("the read element of the test failed.\n");
           break;
        case 15:
-          pout ("(%4d)\tSelf-test routine in progress...\n\t\t\t\t\t",
+          pout("(%4d)\tSelf-test routine in progress...\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("%1d0%% of test remaining.\n", 
+          pout("%1d0%% of test remaining.\n", 
                   data.self_test_exec_status & 0x0f);
           break;
        default:
-          pout ("(%4d)\tReserved.\n",
+          pout("(%4d)\tReserved.\n",
                   data.self_test_exec_status);
           break;
    }
@@ -244,13 +244,13 @@ void PrintSmartTotalTimeCompleteOffline ( struct ata_smart_values data){
 
 void PrintSmartOfflineCollectCap ( struct ata_smart_values data)
 {
-   pout ("Offline data collection\n");
-   pout ("capabilities: \t\t\t (0x%02x) ",
+   pout("Offline data collection\n");
+   pout("capabilities: \t\t\t (0x%02x) ",
             data.offline_data_collection_capability);
 
    if (data.offline_data_collection_capability == 0x00)
    {
-      pout ("\tOff-line data collection not supported.\n");
+      pout("\tOff-line data collection not supported.\n");
    } 
    else 
    {
@@ -280,12 +280,12 @@ void PrintSmartOfflineCollectCap ( struct ata_smart_values data)
 
 void PrintSmartCapability ( struct ata_smart_values data)
 {
-   pout ("SMART capabilities:            ");
-   pout ("(0x%04x)\t", data.smart_capability);
+   pout("SMART capabilities:            ");
+   pout("(0x%04x)\t", data.smart_capability);
    
    if (data.smart_capability == 0x00)
    {
-       pout ("Automatic saving of SMART data\t\t\t\t\tis not implemented.\n");
+       pout("Automatic saving of SMART data\t\t\t\t\tis not implemented.\n");
    } 
    else 
    {
@@ -296,7 +296,7 @@ void PrintSmartCapability ( struct ata_smart_values data)
 		
       if ( data.smart_capability & 0x02 )
       {
-          pout ("\t\t\t\t\tSupports SMART auto save timer.\n");
+          pout("\t\t\t\t\tSupports SMART auto save timer.\n");
       }
    }
 }
@@ -306,15 +306,15 @@ void PrintSmartCapability ( struct ata_smart_values data)
 void PrintSmartErrorLogCapability ( struct ata_smart_values data)
 {
 
-   pout ("Error logging capability:       ");
+   pout("Error logging capability:       ");
     
    if ( isSmartErrorLogCapable(data) )
    {
-      pout (" (0x%02x)\tError logging supported.\n",
+      pout(" (0x%02x)\tError logging supported.\n",
                data.errorlog_capability);
    }
    else {
-       pout (" (0x%02x)\tError logging NOT supported.\n",
+       pout(" (0x%02x)\tError logging NOT supported.\n",
                 data.errorlog_capability);
    }
 }
@@ -325,15 +325,15 @@ void PrintSmartShortSelfTestPollingTime ( struct ata_smart_values data)
 {
    if ( isSupportSelfTest(data) )
    {
-      pout ("Short self-test routine \n");
-      pout ("recommended polling time: \t (%4d) minutes.\n", 
+      pout("Short self-test routine \n");
+      pout("recommended polling time: \t (%4d) minutes.\n", 
                data.short_test_completion_time);
 
    }
    else
    {
-      pout ("Short self-test routine \n");
-      pout ("recommended polling time: \t        Not Supported.\n");
+      pout("Short self-test routine \n");
+      pout("recommended polling time: \t        Not Supported.\n");
    }
 }
 
@@ -342,14 +342,14 @@ void PrintSmartExtendedSelfTestPollingTime ( struct ata_smart_values data)
 {
    if ( isSupportSelfTest(data) )
    {
-      pout ("Extended self-test routine \n");
-      pout ("recommended polling time: \t (%4d) minutes.\n", 
+      pout("Extended self-test routine \n");
+      pout("recommended polling time: \t (%4d) minutes.\n", 
                data.extend_test_completion_time);
    }
    else
    {
-      pout ("Extended self-test routine \n");
-      pout ("recommended polling time: \t        Not Supported.\n");
+      pout("Extended self-test routine \n");
+      pout("recommended polling time: \t        Not Supported.\n");
    }
 }
 
@@ -389,8 +389,8 @@ void PrintSmartAttribWithThres (struct ata_smart_values data,
       // print header only if needed
       if (needheader){
 	if (!onlyfailed){
-	  pout ("SMART Attributes Data Structure revision number: %i\n",data.revnumber);
-	  pout ("Vendor Specific SMART Attributes with Thresholds:\n");
+	  pout("SMART Attributes Data Structure revision number: %i\n",data.revnumber);
+	  pout("Vendor Specific SMART Attributes with Thresholds:\n");
 	}
 	pout("ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE     WHEN_FAILED RAW_VALUE\n");
 	needheader=0;
@@ -426,15 +426,15 @@ void PrintSmartAttribWithThres (struct ata_smart_values data,
       case 9:
 	if (con->smart009minutes)
 	  // minutes
-	  pout ("%llu h + %2llu m\n",rawvalue/60,rawvalue%60);
+	  pout("%llu h + %2llu m\n",rawvalue/60,rawvalue%60);
 	else
 	   // hours
-	  pout ("%llu\n", rawvalue);  //stored in hours
+	  pout("%llu\n", rawvalue);  //stored in hours
 	break;
 	
 	// Temperature
       case 194:
-	pout ("%hhu", disk->raw[0]);
+	pout("%hhu", disk->raw[0]);
 	if (rawvalue==disk->raw[0])
 	  pout("\n");
 	else
@@ -461,7 +461,7 @@ void PrintSmartAttribWithThres (struct ata_smart_values data,
 
 
 void ataPrintGeneralSmartValues(struct ata_smart_values data){
-  pout ("General SMART Values:\n");
+  pout("General SMART Values:\n");
   
   PrintSmartOfflineStatus(data); 
   
@@ -486,12 +486,12 @@ void ataPrintSmartThresholds (struct ata_smart_thresholds data)
 {
    int i;
 
-   pout ("SMART Thresholds\n");
-   pout ("SMART Threshold Revision Number: %i\n", data.revnumber);
+   pout("SMART Thresholds\n");
+   pout("SMART Threshold Revision Number: %i\n", data.revnumber);
 	
    for ( i = 0 ; i < NUMBER_ATA_SMART_ATTRIBUTES ; i++) {
       if (data.thres_entries[i].id)	
-          pout ("Attribute %3i threshold: %02x (%2i)\n", 
+          pout("Attribute %3i threshold: %02x (%2i)\n", 
                    data.thres_entries[i].id, 
                    data.thres_entries[i].threshold, 
                    data.thres_entries[i].threshold);
@@ -512,11 +512,11 @@ int nonempty(unsigned char *testarea,int n){
 void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
   int i,j,k;
   
-  pout ("SMART Error Log Version: %i\n", data.revnumber);
+  pout("SMART Error Log Version: %i\n", data.revnumber);
   
   // if no errors logged, return
   if (!data.error_log_pointer){
-    pout ("No Errors Logged\n\n");
+    pout("No Errors Logged\n\n");
     return;
   }
   QUIETON(con);
@@ -530,9 +530,9 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
   
   // starting printing error log info
   if (data.ata_error_count<=5)
-    pout ( "ATA Error Count: %u\n", data.ata_error_count);
+    pout( "ATA Error Count: %u\n", data.ata_error_count);
   else
-    pout ( "ATA Error Count: %u (device log contains only the most recent five errors)\n",
+    pout( "ATA Error Count: %u (device log contains only the most recent five errors)\n",
 	   data.ata_error_count);
   QUIETOFF(con);
   pout("\tDCR = Device Control Register\n");
@@ -587,7 +587,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
 	
 	// Spec says: unused data command structures shall be zero filled
 	if (nonempty((unsigned char*)thiscommand,sizeof(*thiscommand)))
-	  pout ( " %02x   %02x   %02x   %02x   %02x   %02x    %02x   %02x     %u.%03u\n", 
+	  pout( " %02x   %02x   %02x   %02x   %02x   %02x    %02x   %02x     %u.%03u\n", 
 		   thiscommand->devicecontrolreg,
 		   thiscommand->featuresreg,
 		   thiscommand->sector_count,
@@ -839,7 +839,7 @@ int ataPrintMain (int fd){
       returnval|=FAILSMART;
     }
     else
-      pout ("SMART Automatic Offline Testing Enabled every four hours.\n");
+      pout("SMART Automatic Offline Testing Enabled every four hours.\n");
   }
   if (con->smartautoofflinedisable){
     if (!isSupportAutomaticTimer(smartval)){
@@ -957,7 +957,7 @@ int ataPrintMain (int fd){
   if (con->testcase==OFFLINE_FULL_SCAN &&  !isSupportExecuteOfflineImmediate(smartval))
     pout("Warning: device does not support Execute Off-Line Immediate function.\n\n");
   else if (!isSupportSelfTest(smartval))
-    pout ("Warning: device does not support Self-Test functions.\n\n");
+    pout("Warning: device does not support Self-Test functions.\n\n");
   
   // Now do the test
   if (ataSmartTest(fd, con->testcase))
@@ -965,11 +965,11 @@ int ataPrintMain (int fd){
   
   // Tell user how long test will take to complete  
   if ((timewait=TestTime(smartval,con->testcase))){ 
-    pout ("Please wait %d %s for test to complete.\n",
+    pout("Please wait %d %s for test to complete.\n",
 	    timewait, con->testcase==OFFLINE_FULL_SCAN?"seconds":"minutes");
     
     if (con->testcase!=SHORT_CAPTIVE_SELF_TEST && con->testcase!=EXTEND_CAPTIVE_SELF_TEST)
-      pout ("Use smartctl -%c to abort test.\n", SMARTSELFTESTABORT);	
+      pout("Use smartctl -%c to abort test.\n", SMARTSELFTESTABORT);	
   }    
   return returnval;
 }
diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp
index b2b9e1611d2c0e5c1ddcaf314639cbe14885675b..8dbc403eee4fc6536778b7343b0533c9b4be0de3 100644
--- a/sm5/ataprint.cpp
+++ b/sm5/ataprint.cpp
@@ -29,7 +29,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid2="$Id: ataprint.cpp,v 1.37 2002/10/29 22:09:52 ballen4705 Exp $"
+const char *CVSid2="$Id: ataprint.cpp,v 1.38 2002/10/29 23:09:28 ballen4705 Exp $"
 CVSID1 CVSID2 CVSID3 CVSID6;
 
 // for passing global control variables
@@ -168,64 +168,64 @@ void PrintSmartOfflineStatus(struct ata_smart_values data){
 
 void PrintSmartSelfExecStatus ( struct ata_smart_values data)
 {
-   pout ("Self-test execution status:      ");
+   pout("Self-test execution status:      ");
    
    switch (data.self_test_exec_status >> 4)
    {
       case 0:
-        pout ("(%4d)\tThe previous self-test routine completed\n\t\t\t\t\t",
+        pout("(%4d)\tThe previous self-test routine completed\n\t\t\t\t\t",
                 data.self_test_exec_status);
-        pout ("without error or no self-test has ever \n\t\t\t\t\tbeen run.\n");
+        pout("without error or no self-test has ever \n\t\t\t\t\tbeen run.\n");
         break;
        case 1:
-         pout ("(%4d)\tThe self-test routine was aborted by\n\t\t\t\t\t",
+         pout("(%4d)\tThe self-test routine was aborted by\n\t\t\t\t\t",
                  data.self_test_exec_status);
-         pout ("the host.\n");
+         pout("the host.\n");
          break;
        case 2:
-         pout ("(%4d)\tThe self-test routine was interrupted\n\t\t\t\t\t",
+         pout("(%4d)\tThe self-test routine was interrupted\n\t\t\t\t\t",
                  data.self_test_exec_status);
-         pout ("by the host with a hard or soft reset.\n");
+         pout("by the host with a hard or soft reset.\n");
          break;
        case 3:
-          pout ("(%4d)\tA fatal error or unknown test error\n\t\t\t\t\t",
+          pout("(%4d)\tA fatal error or unknown test error\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("occurred while the device was executing\n\t\t\t\t\t");
-          pout ("its self-test routine and the device \n\t\t\t\t\t");
-          pout ("was unable to complete the self-test \n\t\t\t\t\t");
-          pout ("routine.\n");
+          pout("occurred while the device was executing\n\t\t\t\t\t");
+          pout("its self-test routine and the device \n\t\t\t\t\t");
+          pout("was unable to complete the self-test \n\t\t\t\t\t");
+          pout("routine.\n");
           break;
        case 4:
-          pout ("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
+          pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("a test element that failed and the test\n\t\t\t\t\t");
-          pout ("element that failed is not known.\n");
+          pout("a test element that failed and the test\n\t\t\t\t\t");
+          pout("element that failed is not known.\n");
           break;
        case 5:
-          pout ("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
+          pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("the electrical element of the test\n\t\t\t\t\t");
-          pout ("failed.\n");
+          pout("the electrical element of the test\n\t\t\t\t\t");
+          pout("failed.\n");
           break;
        case 6:
-          pout ("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
+          pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("the servo (and/or seek) element of the \n\t\t\t\t\t");
-          pout ("test failed.\n");
+          pout("the servo (and/or seek) element of the \n\t\t\t\t\t");
+          pout("test failed.\n");
           break;
        case 7:
-          pout ("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
+          pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("the read element of the test failed.\n");
+          pout("the read element of the test failed.\n");
           break;
        case 15:
-          pout ("(%4d)\tSelf-test routine in progress...\n\t\t\t\t\t",
+          pout("(%4d)\tSelf-test routine in progress...\n\t\t\t\t\t",
                   data.self_test_exec_status);
-          pout ("%1d0%% of test remaining.\n", 
+          pout("%1d0%% of test remaining.\n", 
                   data.self_test_exec_status & 0x0f);
           break;
        default:
-          pout ("(%4d)\tReserved.\n",
+          pout("(%4d)\tReserved.\n",
                   data.self_test_exec_status);
           break;
    }
@@ -244,13 +244,13 @@ void PrintSmartTotalTimeCompleteOffline ( struct ata_smart_values data){
 
 void PrintSmartOfflineCollectCap ( struct ata_smart_values data)
 {
-   pout ("Offline data collection\n");
-   pout ("capabilities: \t\t\t (0x%02x) ",
+   pout("Offline data collection\n");
+   pout("capabilities: \t\t\t (0x%02x) ",
             data.offline_data_collection_capability);
 
    if (data.offline_data_collection_capability == 0x00)
    {
-      pout ("\tOff-line data collection not supported.\n");
+      pout("\tOff-line data collection not supported.\n");
    } 
    else 
    {
@@ -280,12 +280,12 @@ void PrintSmartOfflineCollectCap ( struct ata_smart_values data)
 
 void PrintSmartCapability ( struct ata_smart_values data)
 {
-   pout ("SMART capabilities:            ");
-   pout ("(0x%04x)\t", data.smart_capability);
+   pout("SMART capabilities:            ");
+   pout("(0x%04x)\t", data.smart_capability);
    
    if (data.smart_capability == 0x00)
    {
-       pout ("Automatic saving of SMART data\t\t\t\t\tis not implemented.\n");
+       pout("Automatic saving of SMART data\t\t\t\t\tis not implemented.\n");
    } 
    else 
    {
@@ -296,7 +296,7 @@ void PrintSmartCapability ( struct ata_smart_values data)
 		
       if ( data.smart_capability & 0x02 )
       {
-          pout ("\t\t\t\t\tSupports SMART auto save timer.\n");
+          pout("\t\t\t\t\tSupports SMART auto save timer.\n");
       }
    }
 }
@@ -306,15 +306,15 @@ void PrintSmartCapability ( struct ata_smart_values data)
 void PrintSmartErrorLogCapability ( struct ata_smart_values data)
 {
 
-   pout ("Error logging capability:       ");
+   pout("Error logging capability:       ");
     
    if ( isSmartErrorLogCapable(data) )
    {
-      pout (" (0x%02x)\tError logging supported.\n",
+      pout(" (0x%02x)\tError logging supported.\n",
                data.errorlog_capability);
    }
    else {
-       pout (" (0x%02x)\tError logging NOT supported.\n",
+       pout(" (0x%02x)\tError logging NOT supported.\n",
                 data.errorlog_capability);
    }
 }
@@ -325,15 +325,15 @@ void PrintSmartShortSelfTestPollingTime ( struct ata_smart_values data)
 {
    if ( isSupportSelfTest(data) )
    {
-      pout ("Short self-test routine \n");
-      pout ("recommended polling time: \t (%4d) minutes.\n", 
+      pout("Short self-test routine \n");
+      pout("recommended polling time: \t (%4d) minutes.\n", 
                data.short_test_completion_time);
 
    }
    else
    {
-      pout ("Short self-test routine \n");
-      pout ("recommended polling time: \t        Not Supported.\n");
+      pout("Short self-test routine \n");
+      pout("recommended polling time: \t        Not Supported.\n");
    }
 }
 
@@ -342,14 +342,14 @@ void PrintSmartExtendedSelfTestPollingTime ( struct ata_smart_values data)
 {
    if ( isSupportSelfTest(data) )
    {
-      pout ("Extended self-test routine \n");
-      pout ("recommended polling time: \t (%4d) minutes.\n", 
+      pout("Extended self-test routine \n");
+      pout("recommended polling time: \t (%4d) minutes.\n", 
                data.extend_test_completion_time);
    }
    else
    {
-      pout ("Extended self-test routine \n");
-      pout ("recommended polling time: \t        Not Supported.\n");
+      pout("Extended self-test routine \n");
+      pout("recommended polling time: \t        Not Supported.\n");
    }
 }
 
@@ -389,8 +389,8 @@ void PrintSmartAttribWithThres (struct ata_smart_values data,
       // print header only if needed
       if (needheader){
 	if (!onlyfailed){
-	  pout ("SMART Attributes Data Structure revision number: %i\n",data.revnumber);
-	  pout ("Vendor Specific SMART Attributes with Thresholds:\n");
+	  pout("SMART Attributes Data Structure revision number: %i\n",data.revnumber);
+	  pout("Vendor Specific SMART Attributes with Thresholds:\n");
 	}
 	pout("ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE     WHEN_FAILED RAW_VALUE\n");
 	needheader=0;
@@ -426,15 +426,15 @@ void PrintSmartAttribWithThres (struct ata_smart_values data,
       case 9:
 	if (con->smart009minutes)
 	  // minutes
-	  pout ("%llu h + %2llu m\n",rawvalue/60,rawvalue%60);
+	  pout("%llu h + %2llu m\n",rawvalue/60,rawvalue%60);
 	else
 	   // hours
-	  pout ("%llu\n", rawvalue);  //stored in hours
+	  pout("%llu\n", rawvalue);  //stored in hours
 	break;
 	
 	// Temperature
       case 194:
-	pout ("%hhu", disk->raw[0]);
+	pout("%hhu", disk->raw[0]);
 	if (rawvalue==disk->raw[0])
 	  pout("\n");
 	else
@@ -461,7 +461,7 @@ void PrintSmartAttribWithThres (struct ata_smart_values data,
 
 
 void ataPrintGeneralSmartValues(struct ata_smart_values data){
-  pout ("General SMART Values:\n");
+  pout("General SMART Values:\n");
   
   PrintSmartOfflineStatus(data); 
   
@@ -486,12 +486,12 @@ void ataPrintSmartThresholds (struct ata_smart_thresholds data)
 {
    int i;
 
-   pout ("SMART Thresholds\n");
-   pout ("SMART Threshold Revision Number: %i\n", data.revnumber);
+   pout("SMART Thresholds\n");
+   pout("SMART Threshold Revision Number: %i\n", data.revnumber);
 	
    for ( i = 0 ; i < NUMBER_ATA_SMART_ATTRIBUTES ; i++) {
       if (data.thres_entries[i].id)	
-          pout ("Attribute %3i threshold: %02x (%2i)\n", 
+          pout("Attribute %3i threshold: %02x (%2i)\n", 
                    data.thres_entries[i].id, 
                    data.thres_entries[i].threshold, 
                    data.thres_entries[i].threshold);
@@ -512,11 +512,11 @@ int nonempty(unsigned char *testarea,int n){
 void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
   int i,j,k;
   
-  pout ("SMART Error Log Version: %i\n", data.revnumber);
+  pout("SMART Error Log Version: %i\n", data.revnumber);
   
   // if no errors logged, return
   if (!data.error_log_pointer){
-    pout ("No Errors Logged\n\n");
+    pout("No Errors Logged\n\n");
     return;
   }
   QUIETON(con);
@@ -530,9 +530,9 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
   
   // starting printing error log info
   if (data.ata_error_count<=5)
-    pout ( "ATA Error Count: %u\n", data.ata_error_count);
+    pout( "ATA Error Count: %u\n", data.ata_error_count);
   else
-    pout ( "ATA Error Count: %u (device log contains only the most recent five errors)\n",
+    pout( "ATA Error Count: %u (device log contains only the most recent five errors)\n",
 	   data.ata_error_count);
   QUIETOFF(con);
   pout("\tDCR = Device Control Register\n");
@@ -587,7 +587,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
 	
 	// Spec says: unused data command structures shall be zero filled
 	if (nonempty((unsigned char*)thiscommand,sizeof(*thiscommand)))
-	  pout ( " %02x   %02x   %02x   %02x   %02x   %02x    %02x   %02x     %u.%03u\n", 
+	  pout( " %02x   %02x   %02x   %02x   %02x   %02x    %02x   %02x     %u.%03u\n", 
 		   thiscommand->devicecontrolreg,
 		   thiscommand->featuresreg,
 		   thiscommand->sector_count,
@@ -839,7 +839,7 @@ int ataPrintMain (int fd){
       returnval|=FAILSMART;
     }
     else
-      pout ("SMART Automatic Offline Testing Enabled every four hours.\n");
+      pout("SMART Automatic Offline Testing Enabled every four hours.\n");
   }
   if (con->smartautoofflinedisable){
     if (!isSupportAutomaticTimer(smartval)){
@@ -957,7 +957,7 @@ int ataPrintMain (int fd){
   if (con->testcase==OFFLINE_FULL_SCAN &&  !isSupportExecuteOfflineImmediate(smartval))
     pout("Warning: device does not support Execute Off-Line Immediate function.\n\n");
   else if (!isSupportSelfTest(smartval))
-    pout ("Warning: device does not support Self-Test functions.\n\n");
+    pout("Warning: device does not support Self-Test functions.\n\n");
   
   // Now do the test
   if (ataSmartTest(fd, con->testcase))
@@ -965,11 +965,11 @@ int ataPrintMain (int fd){
   
   // Tell user how long test will take to complete  
   if ((timewait=TestTime(smartval,con->testcase))){ 
-    pout ("Please wait %d %s for test to complete.\n",
+    pout("Please wait %d %s for test to complete.\n",
 	    timewait, con->testcase==OFFLINE_FULL_SCAN?"seconds":"minutes");
     
     if (con->testcase!=SHORT_CAPTIVE_SELF_TEST && con->testcase!=EXTEND_CAPTIVE_SELF_TEST)
-      pout ("Use smartctl -%c to abort test.\n", SMARTSELFTESTABORT);	
+      pout("Use smartctl -%c to abort test.\n", SMARTSELFTESTABORT);	
   }    
   return returnval;
 }
diff --git a/sm5/findbadprint b/sm5/findbadprint
deleted file mode 100755
index 953d69a1f320a5e7a8b3b1f0ce863cce19ef6c19..0000000000000000000000000000000000000000
--- a/sm5/findbadprint
+++ /dev/null
@@ -1,43 +0,0 @@
-#! /bin/bash
-# This is a useful little script for debugging print statements.
-# The point is that since we use our own varargs print function,
-# the poor compiler can't check to see for example if there is agreement
-# between the numbers of arguments and format flags.
-
-# Running this script replaces the different printout() and pout() statments
-# with 100% genuine printfs.  A few seconds of hand editing to eliminate the
-# original defs, and you can get compiler warning messages.
-
-# Note: use this script in a COPY of your working directory.  Else it will
-# trash stuff. Use ./findbadprint to go one way, ./findbadprint Q to restore
-# the files as they were.
-
-restore () {
-	mv $1.save $1
-}
-
-
-hackfile () {
-	# first arg filename
-	cp $1 $1.save
-	cat $1.save   	| sed 's/printout(LOG_INFO,/printf(/g' \
-        	      	| sed 's/printout(LOG_CRIT,/printf(/g' \
-             		| sed 's/pout(/printf(/g' > $1
-}
-
-
-if [ $# -eq  0 ] ; then
-
-hackfile smartd.c
-hackfile atacmds.c
-hackfile ataprint.c
-hackfile smartctl.c
-
-else
-
-restore smartd.c
-restore atacmds.c
-restore ataprint.c
-restore smartctl.c
-
-fi
diff --git a/sm5/smartd.c b/sm5/smartd.c
index fb3415efb11f073c071cfe3b09afd33f78f4cddf..12c7d06ee88e9c2df66d5cec99f9141a45795b3e 100644
--- a/sm5/smartd.c
+++ b/sm5/smartd.c
@@ -44,15 +44,15 @@
 
 // CVS ID strings
 extern const char *CVSid1, *CVSid2;
-const char *CVSid6="$Id: smartd.c,v 1.44 2002/10/29 17:50:58 ballen4705 Exp $" 
+const char *CVSid6="$Id: smartd.c,v 1.45 2002/10/29 23:09:29 ballen4705 Exp $" 
 CVSID1 CVSID2 CVSID3 CVSID4 CVSID7;
 
 // global variable used for control of printing, passing arguments, etc.
 atamainctrl *con=NULL;
 
 // Two other globals -- number of ATA and SCSI devices being monitored
-int numatadevices;
-int numscsidevices;
+int numatadevices=0;
+int numscsidevices=0;
 
 // How long to sleep between checks.  Handy as global variable for
 // debugging
@@ -430,7 +430,7 @@ int scsidevicescan(scsidevices_t *devices, char *device){
 int  ataCompareSmartValues2(struct ata_smart_values *new,
 			    struct ata_smart_values *old,
 			    struct ata_smart_thresholds *thresholds,
-			    int n){
+			    int n, char *name){
   struct ata_smart_attribute *now,*was;
   struct ata_smart_threshold_entry *thre;
   unsigned char oldval,newval;
@@ -445,9 +445,17 @@ int  ataCompareSmartValues2(struct ata_smart_values *new,
   was=old->vendor_attributes+n;
   thre=thresholds->thres_entries+n;
 
-  // consider only valid attributes, with same valid ID in all structures
-  if (!now->id || !was->id || !thre->id || (now->id != was->id) || (now->id != thre->id))
+  // consider only valid attributes
+  if (!now->id || !was->id || !thre->id)
     return 0;
+  
+  
+  // issue warning if they don't have the same ID in all structures:
+  if ( (now->id != was->id) || (now->id != thre->id) ){
+    printout(LOG_INFO,"Device: %s, same Attribute has different ID numbers: %hhu = %hhu = %hhu\n",
+	     name, now->id, was->id, thre->id);
+    return 0;
+  }
 
   // if values have not changed, return
   newval=now->current;
@@ -538,12 +546,12 @@ int ataCheckDevice(atadevices_t *drive){
 	    while (*loc && *loc==' ') loc++;
 	    
 	    // warning message
-	    printout(LOG_CRIT,"Device: %s, Failed SMART usage attribute: %s.\n", name, loc, name);
+	    printout(LOG_CRIT,"Device: %s, Failed SMART usage attribute: %s.\n", name, loc);
 	  }
 	}
 	
 	// This block tracks usage or prefailure attributes to see if they are changing
-	if ((cfg->usage || cfg->prefail) && ((att=ataCompareSmartValues2(&curval, drive->smartval, thresh, i)))){
+	if ((cfg->usage || cfg->prefail) && ((att=ataCompareSmartValues2(&curval, drive->smartval, thresh, i, name)))){
 	  const int mask=0xff;
 	  int prefail=(att>>24) & mask;
 	  int id     =(att>>16) & mask;
@@ -1085,9 +1093,6 @@ int main (int argc, char **argv){
   con=&control;
   memset(con,0,sizeof(control));
   
-  // initialize global counters
-  numatadevices=numscsidevices=0;
-  
   // Parse input and print header and usage info if needed
   ParseOpts(argc,argv);
   
diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp
index 6ea6947444397103441db6cd13f549b0fe6b60bd..e9c44df0411518f213736d49cd3038c776a82416 100644
--- a/sm5/smartd.cpp
+++ b/sm5/smartd.cpp
@@ -44,15 +44,15 @@
 
 // CVS ID strings
 extern const char *CVSid1, *CVSid2;
-const char *CVSid6="$Id: smartd.cpp,v 1.44 2002/10/29 17:50:58 ballen4705 Exp $" 
+const char *CVSid6="$Id: smartd.cpp,v 1.45 2002/10/29 23:09:29 ballen4705 Exp $" 
 CVSID1 CVSID2 CVSID3 CVSID4 CVSID7;
 
 // global variable used for control of printing, passing arguments, etc.
 atamainctrl *con=NULL;
 
 // Two other globals -- number of ATA and SCSI devices being monitored
-int numatadevices;
-int numscsidevices;
+int numatadevices=0;
+int numscsidevices=0;
 
 // How long to sleep between checks.  Handy as global variable for
 // debugging
@@ -430,7 +430,7 @@ int scsidevicescan(scsidevices_t *devices, char *device){
 int  ataCompareSmartValues2(struct ata_smart_values *new,
 			    struct ata_smart_values *old,
 			    struct ata_smart_thresholds *thresholds,
-			    int n){
+			    int n, char *name){
   struct ata_smart_attribute *now,*was;
   struct ata_smart_threshold_entry *thre;
   unsigned char oldval,newval;
@@ -445,9 +445,17 @@ int  ataCompareSmartValues2(struct ata_smart_values *new,
   was=old->vendor_attributes+n;
   thre=thresholds->thres_entries+n;
 
-  // consider only valid attributes, with same valid ID in all structures
-  if (!now->id || !was->id || !thre->id || (now->id != was->id) || (now->id != thre->id))
+  // consider only valid attributes
+  if (!now->id || !was->id || !thre->id)
     return 0;
+  
+  
+  // issue warning if they don't have the same ID in all structures:
+  if ( (now->id != was->id) || (now->id != thre->id) ){
+    printout(LOG_INFO,"Device: %s, same Attribute has different ID numbers: %hhu = %hhu = %hhu\n",
+	     name, now->id, was->id, thre->id);
+    return 0;
+  }
 
   // if values have not changed, return
   newval=now->current;
@@ -538,12 +546,12 @@ int ataCheckDevice(atadevices_t *drive){
 	    while (*loc && *loc==' ') loc++;
 	    
 	    // warning message
-	    printout(LOG_CRIT,"Device: %s, Failed SMART usage attribute: %s.\n", name, loc, name);
+	    printout(LOG_CRIT,"Device: %s, Failed SMART usage attribute: %s.\n", name, loc);
 	  }
 	}
 	
 	// This block tracks usage or prefailure attributes to see if they are changing
-	if ((cfg->usage || cfg->prefail) && ((att=ataCompareSmartValues2(&curval, drive->smartval, thresh, i)))){
+	if ((cfg->usage || cfg->prefail) && ((att=ataCompareSmartValues2(&curval, drive->smartval, thresh, i, name)))){
 	  const int mask=0xff;
 	  int prefail=(att>>24) & mask;
 	  int id     =(att>>16) & mask;
@@ -1085,9 +1093,6 @@ int main (int argc, char **argv){
   con=&control;
   memset(con,0,sizeof(control));
   
-  // initialize global counters
-  numatadevices=numscsidevices=0;
-  
   // Parse input and print header and usage info if needed
   ParseOpts(argc,argv);
   
diff --git a/sm5/smartd.h b/sm5/smartd.h
index 281058685684266683f8bd914f6d1762f1710299..c7b0f22b1d2e747a95bc25c655d247868fbc708a 100644
--- a/sm5/smartd.h
+++ b/sm5/smartd.h
@@ -23,7 +23,7 @@
  */
 
 #ifndef CVSID7
-#define CVSID7 "$Id: smartd.h,v 1.14 2002/10/29 17:50:59 ballen4705 Exp $\n"
+#define CVSID7 "$Id: smartd.h,v 1.15 2002/10/29 23:09:29 ballen4705 Exp $\n"
 #endif
 
 // Configuration file
@@ -82,7 +82,7 @@ typedef struct configfile_s {
   char errorlog;
   // counts of ata and self-test errors.  Perhaps ought to be in the
   // atadevices_t structure.
-  char selflogcount;
+  unsigned char selflogcount;
   int  ataerrorcount;
   // following two items point to 32 bytes, in the form of
   // 32x8=256 single bit flags