diff --git a/sm5/atacmds.c b/sm5/atacmds.c
index 52706b833185f3b6554db1a3ba7b292e3fcebbd8..f4dbd8e4194b604cb0e77b55ba9d573fa9a1d5d4 100644
--- a/sm5/atacmds.c
+++ b/sm5/atacmds.c
@@ -30,7 +30,7 @@
 #include <errno.h>
 #include "atacmds.h"
 
-const char *CVSid1="$Id: atacmds.c,v 1.19 2002/10/23 12:24:24 ballen4705 Exp $\n" "\t" CVSID1 ;
+const char *CVSid1="$Id: atacmds.c,v 1.20 2002/10/23 13:43:42 ballen4705 Exp $\n" "\t" 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
@@ -561,7 +561,7 @@ int ataSmartTest(int device, int testtype){
 
   // Now send the command to test
   errornum=ioctl(device, HDIO_DRIVE_CMD, parms);
-  if (!(errornum && errno==EIO && (testtype=SHORT_CAPTIVE_SELF_TEST || testtype==EXTEND_CAPTIVE_SELF_TEST))){
+  if (errornum && !((testtype=SHORT_CAPTIVE_SELF_TEST || testtype==EXTEND_CAPTIVE_SELF_TEST) && errno==EIO)){
     char errormsg[128];
     sprintf(errormsg,"Command \"%s\" failed",cmdmsg); 
     perror(errormsg);
diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp
index 98eabac4dafbc7161af9df09aca04d6d4756b4b6..faee25e67f7c125f000c23c7a67928a214f70340 100644
--- a/sm5/atacmds.cpp
+++ b/sm5/atacmds.cpp
@@ -30,7 +30,7 @@
 #include <errno.h>
 #include "atacmds.h"
 
-const char *CVSid1="$Id: atacmds.cpp,v 1.19 2002/10/23 12:24:24 ballen4705 Exp $\n" "\t" CVSID1 ;
+const char *CVSid1="$Id: atacmds.cpp,v 1.20 2002/10/23 13:43:42 ballen4705 Exp $\n" "\t" 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
@@ -561,7 +561,7 @@ int ataSmartTest(int device, int testtype){
 
   // Now send the command to test
   errornum=ioctl(device, HDIO_DRIVE_CMD, parms);
-  if (!(errornum && errno==EIO && (testtype=SHORT_CAPTIVE_SELF_TEST || testtype==EXTEND_CAPTIVE_SELF_TEST))){
+  if (errornum && !((testtype=SHORT_CAPTIVE_SELF_TEST || testtype==EXTEND_CAPTIVE_SELF_TEST) && errno==EIO)){
     char errormsg[128];
     sprintf(errormsg,"Command \"%s\" failed",cmdmsg); 
     perror(errormsg);
diff --git a/sm5/ataprint.c b/sm5/ataprint.c
index bb0cb8c8f6b5f621b8249a79100ffa6242e5fa13..0c3e8120c45d693f4a12584cabb81c15d669504d 100644
--- a/sm5/ataprint.c
+++ b/sm5/ataprint.c
@@ -28,7 +28,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid4="$Id: ataprint.c,v 1.26 2002/10/23 12:37:11 ballen4705 Exp $\n"
+const char *CVSid4="$Id: ataprint.c,v 1.27 2002/10/23 13:43:42 ballen4705 Exp $\n"
 	           "\t" CVSID2 "\t" CVSID3 "\t" CVSID6 ;
 
 // Function for printing ASCII byte-swapped strings, skipping white
@@ -665,12 +665,7 @@ int ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data,int allentries){
 	pout("#%2d  %s %s %s  %8u         %s\n",21-i,msgtest,msgstat,
 	     percent,log->timestamp,firstlba);
     }
-    else {
-      pout("\n");
-      return retval;
-    }
   }
-  pout("\n");
   return retval;
 }
 
@@ -1021,6 +1016,7 @@ int ataPrintMain (int fd){
 	if (ataPrintSmartSelfTestlog(smartselftest,!quietmode))
 	  returnval|=FAILLOG;
 	QUIETOFF;
+	pout("\n");
       }
     } 
   }
@@ -1030,7 +1026,6 @@ int ataPrintMain (int fd){
     return returnval;
   
   pout("=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===\n");
-  
   // if doing a self-test, be sure it's supported by the hardware
   if (testcase==OFFLINE_FULL_SCAN &&  !isSupportExecuteOfflineImmediate(smartval))
     pout("Warning: device does not support Execute Off-Line Immediate function.\n\n");
diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp
index a7453261354bf3f0b3c72db49ef8cea02b413dd1..e3ad6135ec579a6d96ee671274bf9e1b1a010142 100644
--- a/sm5/ataprint.cpp
+++ b/sm5/ataprint.cpp
@@ -28,7 +28,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid4="$Id: ataprint.cpp,v 1.26 2002/10/23 12:37:11 ballen4705 Exp $\n"
+const char *CVSid4="$Id: ataprint.cpp,v 1.27 2002/10/23 13:43:42 ballen4705 Exp $\n"
 	           "\t" CVSID2 "\t" CVSID3 "\t" CVSID6 ;
 
 // Function for printing ASCII byte-swapped strings, skipping white
@@ -665,12 +665,7 @@ int ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data,int allentries){
 	pout("#%2d  %s %s %s  %8u         %s\n",21-i,msgtest,msgstat,
 	     percent,log->timestamp,firstlba);
     }
-    else {
-      pout("\n");
-      return retval;
-    }
   }
-  pout("\n");
   return retval;
 }
 
@@ -1021,6 +1016,7 @@ int ataPrintMain (int fd){
 	if (ataPrintSmartSelfTestlog(smartselftest,!quietmode))
 	  returnval|=FAILLOG;
 	QUIETOFF;
+	pout("\n");
       }
     } 
   }
@@ -1030,7 +1026,6 @@ int ataPrintMain (int fd){
     return returnval;
   
   pout("=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===\n");
-  
   // if doing a self-test, be sure it's supported by the hardware
   if (testcase==OFFLINE_FULL_SCAN &&  !isSupportExecuteOfflineImmediate(smartval))
     pout("Warning: device does not support Execute Off-Line Immediate function.\n\n");