diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG index 7729cc0b27fb17d6d363cda2f75c82386d6d4a85..578fdd93c71e60ae8cdca61cfab145f02bd38654 100644 --- a/sm5/CHANGELOG +++ b/sm5/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG for smartmontools -$Id: CHANGELOG,v 1.30 2002/10/29 23:18:29 ballen4705 Exp $ +$Id: CHANGELOG,v 1.31 2002/10/30 06:02:37 ballen4705 Exp $ Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> @@ -26,8 +26,20 @@ NOTES FOR FUTURE RELEASES: see TODO file. CURRENT RELEASE (see VERSION file in this directory): +smartmontools-5.0.23 -smartmontools-5.0.21 + Because of reported problems with GCC 3.2 compile, I have gone + thorough the code and explicitly changed all print format + parameters to correspond EXACTLY to int unless they have to be + promoted to long longs. To quote from the glibc bible: [From + GLIBC Manual: Since the prototype doesn't specify types for + optional arguments, in a call to a variadic function the default + argument promotions are performed on the optional argument + values. This means the objects of type char or short int (whether + signed or not) are promoted to either int or unsigned int, as + appropriate.] + +smartmontools-5.0.22 smartd, smartctl now warn if they find an attribute whose ID number does not match between Data and Threshold structures. diff --git a/sm5/Makefile b/sm5/Makefile index aeb44562014e8920b2dd978bdbe2728a630011e9..dd95a25766731e532facbbb28806631d48bf79d7 100644 --- a/sm5/Makefile +++ b/sm5/Makefile @@ -2,7 +2,7 @@ # # Home page: http://smartmontools.sourceforge.net # -# $Id: Makefile,v 1.29 2002/10/29 21:58:25 ballen4705 Exp $ +# $Id: Makefile,v 1.30 2002/10/30 06:02:38 ballen4705 Exp $ # # Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> # @@ -29,7 +29,10 @@ CC = gcc # CFLAGS = -fsigned-char -Wall -O2 -I./usr/src/linux-2.4/include # Normal build -CFLAGS = -fsigned-char -Wall -O2 +# NOTE: I have had reports that with gcc 3.2 this code fails if you use anything but +# -Os. I'll remove this comment when this is resolved, or I am reminded of it! +# If you are getting strange output from gcc 3.2 try changing O2 to Os. +CFLAGS = -fsigned-char -Wall -O2 releasefiles=atacmds.c atacmds.h ataprint.c ataprint.h CHANGELOG COPYING extern.h Makefile\ README scsicmds.c scsicmds.h scsiprint.c scsiprint.h smartctl.8 smartctl.c smartctl.h\ diff --git a/sm5/VERSION b/sm5/VERSION index 2bd5a0a98a36cc08ada88b804d3be047e6aa5b8a..409940768f2a684935a7d15a29f96e82c487f439 100644 --- a/sm5/VERSION +++ b/sm5/VERSION @@ -1 +1 @@ -22 +23 diff --git a/sm5/atacmds.c b/sm5/atacmds.c index df6b04a9b28cf5f416a2354d81282594e891e05f..b78c270cb0af7fa75337f1518a075c3f523a5b16 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.34 2002/10/30 00:56:19 ballen4705 Exp $" CVSID1; +const char *CVSid1="$Id: atacmds.c,v 1.35 2002/10/30 06:02:38 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 @@ -515,13 +515,13 @@ int ataSmartStatus2(int device){ perror("Error SMART Status command failed"); pout("Please get assistance from %s\n",PROJECTHOME); pout("Register values returned from SMART Status command are:\n"); - pout("CMD=0x%02x\n",parms[0]); - pout("FR =0x%02x\n",parms[1]); - pout("NS =0x%02x\n",parms[2]); - pout("SC =0x%02x\n",parms[3]); - pout("CL =0x%02x\n",parms[4]); - pout("CH =0x%02x\n",parms[5]); - pout("SEL=0x%02x\n",parms[6]); + pout("CMD=0x%02x\n",(int)parms[0]); + pout("FR =0x%02x\n",(int)parms[1]); + pout("NS =0x%02x\n",(int)parms[2]); + pout("SC =0x%02x\n",(int)parms[3]); + pout("CL =0x%02x\n",(int)parms[4]); + pout("CH =0x%02x\n",(int)parms[5]); + pout("SEL=0x%02x\n",(int)parms[6]); return -1; } #else diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index 127644ef7a2abd893d4e024cc3cecee8318039e0..21a84b46fc100f39937e91ffd380f1a43eec307d 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.34 2002/10/30 00:56:19 ballen4705 Exp $" CVSID1; +const char *CVSid1="$Id: atacmds.cpp,v 1.35 2002/10/30 06:02:38 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 @@ -515,13 +515,13 @@ int ataSmartStatus2(int device){ perror("Error SMART Status command failed"); pout("Please get assistance from %s\n",PROJECTHOME); pout("Register values returned from SMART Status command are:\n"); - pout("CMD=0x%02x\n",parms[0]); - pout("FR =0x%02x\n",parms[1]); - pout("NS =0x%02x\n",parms[2]); - pout("SC =0x%02x\n",parms[3]); - pout("CL =0x%02x\n",parms[4]); - pout("CH =0x%02x\n",parms[5]); - pout("SEL=0x%02x\n",parms[6]); + pout("CMD=0x%02x\n",(int)parms[0]); + pout("FR =0x%02x\n",(int)parms[1]); + pout("NS =0x%02x\n",(int)parms[2]); + pout("SC =0x%02x\n",(int)parms[3]); + pout("CL =0x%02x\n",(int)parms[4]); + pout("CH =0x%02x\n",(int)parms[5]); + pout("SEL=0x%02x\n",(int)parms[6]); return -1; } #else diff --git a/sm5/atacmds.h b/sm5/atacmds.h index d3df6b93d2f7e81b1162571011717ac8cb9ca0d8..5140c89ef150d4c4d07bab86720895acc7f4f2df 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.22 2002/10/29 23:09:28 ballen4705 Exp $\n" +#define CVSID1 "$Id: atacmds.h,v 1.23 2002/10/30 06:02:39 ballen4705 Exp $\n" #endif // These are the major and minor versions for smartd and smartctl @@ -347,7 +347,10 @@ int TestTime(struct ata_smart_values data,int testtype); void ataPrintSmartAttribName(char *output, unsigned char id); // like printf() except that we can control it better.... -void pout(char *fmt, ...); +void pout(char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + + // utility function for printing out CVS strings #define CVSMAXLEN 512 diff --git a/sm5/ataprint.c b/sm5/ataprint.c index f882e2b9c32fee5c133f4cc9c0b2c7f82d8e6b6a..e4ceb9a10371a6cbe238d7995425089180baa149 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.38 2002/10/29 23:09:28 ballen4705 Exp $" +const char *CVSid2="$Id: ataprint.c,v 1.39 2002/10/30 06:02:39 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID6; // for passing global control variables @@ -84,7 +84,7 @@ void ataPrintDriveInfo (struct hd_driveid drive){ // unrecognized minor revision code if (!description){ - sprintf(unknown,"Unrecognized. Minor revision code: 0x%02x",minorrev); + sprintf(unknown,"Unrecognized. Minor revision code: 0x%02hx",minorrev); description=unknown; } @@ -95,7 +95,7 @@ void ataPrintDriveInfo (struct hd_driveid drive){ // http://www.t13.org/project/d2008r6.pdf to see this. So it's not // enough to check if we are ATA-3. Version=-3 indicates ATA-3 // BEFORE Revision 3. - pout("ATA Version is: %i\n",version>0?version:-1*version); + pout("ATA Version is: %d\n",(int)abs(version)); pout("ATA Standard is: %s\n",description); if (version>=3) @@ -116,41 +116,41 @@ void PrintSmartOfflineStatus(struct ata_smart_values data){ case 0x00: case 0x80: pout("(0x%02x)\tOffline data collection activity was\n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("never started.\n"); break; case 0x01: case 0x81: pout("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); break; case 0x02: case 0x82: pout("(0x%02x)\tOffline data collection activity \n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("completed without error.\n"); break; case 0x03: case 0x83: pout("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); break; case 0x04: case 0x84: pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("suspended by an interrupting command from host.\n"); break; case 0x05: case 0x85: pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("aborted by an interrupting command from host.\n"); break; case 0x06: case 0x86: pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("aborted by the device with a fatal error.\n"); break; default: @@ -158,9 +158,9 @@ void PrintSmartOfflineStatus(struct ata_smart_values data){ (data.offline_data_collection_status <= 0x3f)) || ((data.offline_data_collection_status >= 0xc0) && (data.offline_data_collection_status <= 0xff)) ) - pout("(0x%02x)\tVendor Specific.\n",data.offline_data_collection_status); + pout("(0x%02x)\tVendor Specific.\n",(int)data.offline_data_collection_status); else - pout("(0x%02x)\tReserved.\n",data.offline_data_collection_status); + pout("(0x%02x)\tReserved.\n",(int)data.offline_data_collection_status); } } @@ -174,22 +174,22 @@ void PrintSmartSelfExecStatus ( struct ata_smart_values data) { case 0: pout("(%4d)\tThe previous self-test routine completed\n\t\t\t\t\t", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)data.self_test_exec_status); pout("the host.\n"); break; case 2: pout("(%4d)\tThe self-test routine was interrupted\n\t\t\t\t\t", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)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"); @@ -197,36 +197,36 @@ void PrintSmartSelfExecStatus ( struct ata_smart_values data) break; case 4: pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t", - data.self_test_exec_status); + (int)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"); break; case 5: pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)data.self_test_exec_status); pout("%1d0%% of test remaining.\n", - data.self_test_exec_status & 0x0f); + (int)(data.self_test_exec_status & 0x0f)); break; default: pout("(%4d)\tReserved.\n", - data.self_test_exec_status); + (int)data.self_test_exec_status); break; } @@ -237,7 +237,7 @@ void PrintSmartSelfExecStatus ( struct ata_smart_values data) void PrintSmartTotalTimeCompleteOffline ( struct ata_smart_values data){ pout("Total time to complete off-line \n"); pout("data collection: \t\t (%4d) seconds.\n", - data.total_time_to_complete_off_line); + (int)data.total_time_to_complete_off_line); } @@ -246,7 +246,7 @@ void PrintSmartOfflineCollectCap ( struct ata_smart_values data) { pout("Offline data collection\n"); pout("capabilities: \t\t\t (0x%02x) ", - data.offline_data_collection_capability); + (int)data.offline_data_collection_capability); if (data.offline_data_collection_capability == 0x00) { @@ -281,7 +281,7 @@ 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("(0x%04x)\t", (int)data.smart_capability); if (data.smart_capability == 0x00) { @@ -311,11 +311,11 @@ void PrintSmartErrorLogCapability ( struct ata_smart_values data) if ( isSmartErrorLogCapable(data) ) { pout(" (0x%02x)\tError logging supported.\n", - data.errorlog_capability); + (int)data.errorlog_capability); } else { pout(" (0x%02x)\tError logging NOT supported.\n", - data.errorlog_capability); + (int)data.errorlog_capability); } } @@ -327,7 +327,7 @@ void PrintSmartShortSelfTestPollingTime ( struct ata_smart_values data) { pout("Short self-test routine \n"); pout("recommended polling time: \t (%4d) minutes.\n", - data.short_test_completion_time); + (int)data.short_test_completion_time); } else @@ -344,7 +344,7 @@ void PrintSmartExtendedSelfTestPollingTime ( struct ata_smart_values data) { pout("Extended self-test routine \n"); pout("recommended polling time: \t (%4d) minutes.\n", - data.extend_test_completion_time); + (int)data.extend_test_completion_time); } else { @@ -389,7 +389,7 @@ 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("SMART Attributes Data Structure revision number: %d\n",(int)data.revnumber); pout("Vendor Specific SMART Attributes with Thresholds:\n"); } pout("ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE WHEN_FAILED RAW_VALUE\n"); @@ -410,9 +410,9 @@ void PrintSmartAttribWithThres (struct ata_smart_values data, // printing line for each valid attribute type=disk->status.flag.prefailure?"Pre-fail":"Old_age"; - pout("0x%04x %.3i %.3i %.3i %-9s%-12s", - disk->status.all, disk->current, disk->worst, - thre->threshold, type, status); + pout("0x%04x %.3d %.3d %.3d %-9s%-12s", + (int)disk->status.all, (int)disk->current, (int)disk->worst, + (int)thre->threshold, type, status); // convert the six individual bytes to a long long (8 byte) integer rawvalue = 0; @@ -424,23 +424,26 @@ void PrintSmartAttribWithThres (struct ata_smart_values data, switch (disk->id){ // Power on time case 9: - if (con->smart009minutes) + if (con->smart009minutes){ // minutes - pout("%llu h + %2llu m\n",rawvalue/60,rawvalue%60); + long long tmp1=rawvalue/60; + long long tmp2=rawvalue%60; + pout("%llu h + %2llu m\n", tmp1, tmp2); + } else - // hours + // hours pout("%llu\n", rawvalue); //stored in hours break; // Temperature case 194: - pout("%hhu", disk->raw[0]); + pout("%d", (int)disk->raw[0]); if (rawvalue==disk->raw[0]) pout("\n"); else // The other bytes are in use. Try IBM's model - pout(" (Lifetime Min/Max %hhu/%hhu)\n",disk->raw[2], - disk->raw[4]); + pout(" (Lifetime Min/Max %d/%d)\n",(int)disk->raw[2], + (int)disk->raw[4]); break; default: pout("%llu\n", rawvalue); @@ -481,24 +484,6 @@ void ataPrintGeneralSmartValues(struct ata_smart_values data){ pout("\n"); } -// Is not (currently) used in ANY code -void ataPrintSmartThresholds (struct ata_smart_thresholds data) -{ - int i; - - 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", - data.thres_entries[i].id, - data.thres_entries[i].threshold, - data.thres_entries[i].threshold); - } -} - - // Returns nonzero if region of memory contains non-zero entries int nonempty(unsigned char *testarea,int n){ int i; @@ -512,7 +497,7 @@ 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: %d\n", (int)data.revnumber); // if no errors logged, return if (!data.error_log_pointer){ @@ -524,16 +509,16 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){ if ( data.error_log_pointer>5 ){ pout("Invalid Error Log index = %02x (T13/1321D rev 1c" "Section 8.41.6.8.2.2 gives valid range from 1 to 5)\n\n", - data.error_log_pointer); + (int)data.error_log_pointer); return; } // 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: %d\n", (int)data.ata_error_count); else - pout( "ATA Error Count: %u (device log contains only the most recent five errors)\n", - data.ata_error_count); + pout( "ATA Error Count: %d (device log contains only the most recent five errors)\n", + (int)data.ata_error_count); QUIETOFF(con); pout("\tDCR = Device Control Register\n"); pout("\tFR = Features Register\n"); @@ -567,19 +552,19 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){ } // See table 42 of ATA5 spec QUIETON(con); - pout("Error %i occurred at disk power-on lifetime: %u hours\n", - 5-k,data.errorlog_struct[i].error_struct.timestamp); + pout("Error %d occurred at disk power-on lifetime: %d hours\n", + (int)(5-k), (int)data.errorlog_struct[i].error_struct.timestamp); QUIETOFF(con); pout("When the command that caused the error occurred, the device was %s.\n",msgstate); pout("After command completion occurred, registers were:\n"); pout("ER:%02x SC:%02x SN:%02x CL:%02x CH:%02x D/H:%02x ST:%02x\n", - data.errorlog_struct[i].error_struct.error_register, - data.errorlog_struct[i].error_struct.sector_count, - data.errorlog_struct[i].error_struct.sector_number, - data.errorlog_struct[i].error_struct.cylinder_low, - data.errorlog_struct[i].error_struct.cylinder_high, - data.errorlog_struct[i].error_struct.drive_head, - data.errorlog_struct[i].error_struct.status); + (int)data.errorlog_struct[i].error_struct.error_register, + (int)data.errorlog_struct[i].error_struct.sector_count, + (int)data.errorlog_struct[i].error_struct.sector_number, + (int)data.errorlog_struct[i].error_struct.cylinder_low, + (int)data.errorlog_struct[i].error_struct.cylinder_high, + (int)data.errorlog_struct[i].error_struct.drive_head, + (int)data.errorlog_struct[i].error_struct.status); pout("Sequence of commands leading to the command that caused the error were:\n"); pout("DCR FR SC SN CL CH D/H CR Timestamp\n"); for ( j = 4; j >= 0; j--){ @@ -587,17 +572,17 @@ 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", - thiscommand->devicecontrolreg, - thiscommand->featuresreg, - thiscommand->sector_count, - thiscommand->sector_number, - thiscommand->cylinder_low, - thiscommand->cylinder_high, - thiscommand->drive_head, - thiscommand->commandreg, - (unsigned int)(thiscommand->timestamp / 1000), - (unsigned int)(thiscommand->timestamp % 1000)); + pout(" %02x %02x %02x %02x %02x %02x %02x %02x %d.%03d\n", + (int)thiscommand->devicecontrolreg, + (int)thiscommand->featuresreg, + (int)thiscommand->sector_count, + (int)thiscommand->sector_number, + (int)thiscommand->cylinder_low, + (int)thiscommand->cylinder_high, + (int)thiscommand->drive_head, + (int)thiscommand->commandreg, + (unsigned int)(thiscommand->timestamp / 1000U), + (unsigned int)(thiscommand->timestamp % 1000U)); } pout("\n"); } @@ -615,8 +600,8 @@ int ataPrintSmartSelfTestlog(struct ata_smart_selftestlog data,int allentries){ int retval=0; if (allentries) - pout("SMART Self-test log, version number %u\n",data.revnumber); - if (data.revnumber!=0x01 && allentries) + pout("SMART Self-test log, version number %d\n",(int)data.revnumber); + if ((data.revnumber!=0x0001) && allentries) pout("Warning - structure revision number does not match spec!\n"); if (data.mostrecenttest==0){ if (allentries) @@ -686,8 +671,8 @@ int ataPrintSmartSelfTestlog(struct ata_smart_selftestlog data,int allentries){ } if (allentries || errorfound) - pout("#%2d %s %s %s %8u %s\n",21-i,msgtest,msgstat, - percent,log->timestamp,firstlba); + pout("#%2d %s %s %s %8d %s\n",21-i,msgtest,msgstat, + percent,(int)log->timestamp,firstlba); } } if (!allentries && retval) @@ -705,7 +690,7 @@ void ataPseudoCheckSmart ( struct ata_smart_values data, data.vendor_attributes[i].status.flag.prefailure && (data.vendor_attributes[i].current <= thresholds.thres_entries[i].threshold) && (thresholds.thres_entries[i].threshold != 0xFE)){ - pout("Attribute ID %i Failed\n",data.vendor_attributes[i].id); + pout("Attribute ID %d Failed\n",(int)data.vendor_attributes[i].id); failed = 1; } } @@ -782,7 +767,7 @@ int ataPrintMain (int fd){ // From here on, every command requires that SMART be enabled... if (!ataDoesSmartWork(fd)) { - pout("SMART Disabled. Use option -%c to enable it.\n", SMARTENABLE ); + pout("SMART Disabled. Use option -%c to enable it.\n", (int)SMARTENABLE ); return returnval; } @@ -792,7 +777,7 @@ int ataPrintMain (int fd){ pout( "Smartctl: SMART Disable Failed.\n\n"); returnval|=FAILSMART; } - pout("SMART Disabled. Use option -%c to enable it.\n",SMARTENABLE); + pout("SMART Disabled. Use option -%c to enable it.\n",(int)SMARTENABLE); return returnval; } @@ -966,10 +951,10 @@ 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", - timewait, con->testcase==OFFLINE_FULL_SCAN?"seconds":"minutes"); + (int)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", (int)SMARTSELFTESTABORT); } return returnval; } diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp index 8dbc403eee4fc6536778b7343b0533c9b4be0de3..19159a7348c774a54f1c5ef5e3fd14b3fb18daf5 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.38 2002/10/29 23:09:28 ballen4705 Exp $" +const char *CVSid2="$Id: ataprint.cpp,v 1.39 2002/10/30 06:02:39 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID6; // for passing global control variables @@ -84,7 +84,7 @@ void ataPrintDriveInfo (struct hd_driveid drive){ // unrecognized minor revision code if (!description){ - sprintf(unknown,"Unrecognized. Minor revision code: 0x%02x",minorrev); + sprintf(unknown,"Unrecognized. Minor revision code: 0x%02hx",minorrev); description=unknown; } @@ -95,7 +95,7 @@ void ataPrintDriveInfo (struct hd_driveid drive){ // http://www.t13.org/project/d2008r6.pdf to see this. So it's not // enough to check if we are ATA-3. Version=-3 indicates ATA-3 // BEFORE Revision 3. - pout("ATA Version is: %i\n",version>0?version:-1*version); + pout("ATA Version is: %d\n",(int)abs(version)); pout("ATA Standard is: %s\n",description); if (version>=3) @@ -116,41 +116,41 @@ void PrintSmartOfflineStatus(struct ata_smart_values data){ case 0x00: case 0x80: pout("(0x%02x)\tOffline data collection activity was\n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("never started.\n"); break; case 0x01: case 0x81: pout("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); break; case 0x02: case 0x82: pout("(0x%02x)\tOffline data collection activity \n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("completed without error.\n"); break; case 0x03: case 0x83: pout("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); break; case 0x04: case 0x84: pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("suspended by an interrupting command from host.\n"); break; case 0x05: case 0x85: pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("aborted by an interrupting command from host.\n"); break; case 0x06: case 0x86: pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); + (int)data.offline_data_collection_status); pout("aborted by the device with a fatal error.\n"); break; default: @@ -158,9 +158,9 @@ void PrintSmartOfflineStatus(struct ata_smart_values data){ (data.offline_data_collection_status <= 0x3f)) || ((data.offline_data_collection_status >= 0xc0) && (data.offline_data_collection_status <= 0xff)) ) - pout("(0x%02x)\tVendor Specific.\n",data.offline_data_collection_status); + pout("(0x%02x)\tVendor Specific.\n",(int)data.offline_data_collection_status); else - pout("(0x%02x)\tReserved.\n",data.offline_data_collection_status); + pout("(0x%02x)\tReserved.\n",(int)data.offline_data_collection_status); } } @@ -174,22 +174,22 @@ void PrintSmartSelfExecStatus ( struct ata_smart_values data) { case 0: pout("(%4d)\tThe previous self-test routine completed\n\t\t\t\t\t", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)data.self_test_exec_status); pout("the host.\n"); break; case 2: pout("(%4d)\tThe self-test routine was interrupted\n\t\t\t\t\t", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)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"); @@ -197,36 +197,36 @@ void PrintSmartSelfExecStatus ( struct ata_smart_values data) break; case 4: pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t", - data.self_test_exec_status); + (int)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"); break; case 5: pout("(%4d)\tThe previous self-test completed having\n\t\t\t\t\t", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)data.self_test_exec_status); 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", - data.self_test_exec_status); + (int)data.self_test_exec_status); pout("%1d0%% of test remaining.\n", - data.self_test_exec_status & 0x0f); + (int)(data.self_test_exec_status & 0x0f)); break; default: pout("(%4d)\tReserved.\n", - data.self_test_exec_status); + (int)data.self_test_exec_status); break; } @@ -237,7 +237,7 @@ void PrintSmartSelfExecStatus ( struct ata_smart_values data) void PrintSmartTotalTimeCompleteOffline ( struct ata_smart_values data){ pout("Total time to complete off-line \n"); pout("data collection: \t\t (%4d) seconds.\n", - data.total_time_to_complete_off_line); + (int)data.total_time_to_complete_off_line); } @@ -246,7 +246,7 @@ void PrintSmartOfflineCollectCap ( struct ata_smart_values data) { pout("Offline data collection\n"); pout("capabilities: \t\t\t (0x%02x) ", - data.offline_data_collection_capability); + (int)data.offline_data_collection_capability); if (data.offline_data_collection_capability == 0x00) { @@ -281,7 +281,7 @@ 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("(0x%04x)\t", (int)data.smart_capability); if (data.smart_capability == 0x00) { @@ -311,11 +311,11 @@ void PrintSmartErrorLogCapability ( struct ata_smart_values data) if ( isSmartErrorLogCapable(data) ) { pout(" (0x%02x)\tError logging supported.\n", - data.errorlog_capability); + (int)data.errorlog_capability); } else { pout(" (0x%02x)\tError logging NOT supported.\n", - data.errorlog_capability); + (int)data.errorlog_capability); } } @@ -327,7 +327,7 @@ void PrintSmartShortSelfTestPollingTime ( struct ata_smart_values data) { pout("Short self-test routine \n"); pout("recommended polling time: \t (%4d) minutes.\n", - data.short_test_completion_time); + (int)data.short_test_completion_time); } else @@ -344,7 +344,7 @@ void PrintSmartExtendedSelfTestPollingTime ( struct ata_smart_values data) { pout("Extended self-test routine \n"); pout("recommended polling time: \t (%4d) minutes.\n", - data.extend_test_completion_time); + (int)data.extend_test_completion_time); } else { @@ -389,7 +389,7 @@ 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("SMART Attributes Data Structure revision number: %d\n",(int)data.revnumber); pout("Vendor Specific SMART Attributes with Thresholds:\n"); } pout("ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE WHEN_FAILED RAW_VALUE\n"); @@ -410,9 +410,9 @@ void PrintSmartAttribWithThres (struct ata_smart_values data, // printing line for each valid attribute type=disk->status.flag.prefailure?"Pre-fail":"Old_age"; - pout("0x%04x %.3i %.3i %.3i %-9s%-12s", - disk->status.all, disk->current, disk->worst, - thre->threshold, type, status); + pout("0x%04x %.3d %.3d %.3d %-9s%-12s", + (int)disk->status.all, (int)disk->current, (int)disk->worst, + (int)thre->threshold, type, status); // convert the six individual bytes to a long long (8 byte) integer rawvalue = 0; @@ -424,23 +424,26 @@ void PrintSmartAttribWithThres (struct ata_smart_values data, switch (disk->id){ // Power on time case 9: - if (con->smart009minutes) + if (con->smart009minutes){ // minutes - pout("%llu h + %2llu m\n",rawvalue/60,rawvalue%60); + long long tmp1=rawvalue/60; + long long tmp2=rawvalue%60; + pout("%llu h + %2llu m\n", tmp1, tmp2); + } else - // hours + // hours pout("%llu\n", rawvalue); //stored in hours break; // Temperature case 194: - pout("%hhu", disk->raw[0]); + pout("%d", (int)disk->raw[0]); if (rawvalue==disk->raw[0]) pout("\n"); else // The other bytes are in use. Try IBM's model - pout(" (Lifetime Min/Max %hhu/%hhu)\n",disk->raw[2], - disk->raw[4]); + pout(" (Lifetime Min/Max %d/%d)\n",(int)disk->raw[2], + (int)disk->raw[4]); break; default: pout("%llu\n", rawvalue); @@ -481,24 +484,6 @@ void ataPrintGeneralSmartValues(struct ata_smart_values data){ pout("\n"); } -// Is not (currently) used in ANY code -void ataPrintSmartThresholds (struct ata_smart_thresholds data) -{ - int i; - - 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", - data.thres_entries[i].id, - data.thres_entries[i].threshold, - data.thres_entries[i].threshold); - } -} - - // Returns nonzero if region of memory contains non-zero entries int nonempty(unsigned char *testarea,int n){ int i; @@ -512,7 +497,7 @@ 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: %d\n", (int)data.revnumber); // if no errors logged, return if (!data.error_log_pointer){ @@ -524,16 +509,16 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){ if ( data.error_log_pointer>5 ){ pout("Invalid Error Log index = %02x (T13/1321D rev 1c" "Section 8.41.6.8.2.2 gives valid range from 1 to 5)\n\n", - data.error_log_pointer); + (int)data.error_log_pointer); return; } // 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: %d\n", (int)data.ata_error_count); else - pout( "ATA Error Count: %u (device log contains only the most recent five errors)\n", - data.ata_error_count); + pout( "ATA Error Count: %d (device log contains only the most recent five errors)\n", + (int)data.ata_error_count); QUIETOFF(con); pout("\tDCR = Device Control Register\n"); pout("\tFR = Features Register\n"); @@ -567,19 +552,19 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){ } // See table 42 of ATA5 spec QUIETON(con); - pout("Error %i occurred at disk power-on lifetime: %u hours\n", - 5-k,data.errorlog_struct[i].error_struct.timestamp); + pout("Error %d occurred at disk power-on lifetime: %d hours\n", + (int)(5-k), (int)data.errorlog_struct[i].error_struct.timestamp); QUIETOFF(con); pout("When the command that caused the error occurred, the device was %s.\n",msgstate); pout("After command completion occurred, registers were:\n"); pout("ER:%02x SC:%02x SN:%02x CL:%02x CH:%02x D/H:%02x ST:%02x\n", - data.errorlog_struct[i].error_struct.error_register, - data.errorlog_struct[i].error_struct.sector_count, - data.errorlog_struct[i].error_struct.sector_number, - data.errorlog_struct[i].error_struct.cylinder_low, - data.errorlog_struct[i].error_struct.cylinder_high, - data.errorlog_struct[i].error_struct.drive_head, - data.errorlog_struct[i].error_struct.status); + (int)data.errorlog_struct[i].error_struct.error_register, + (int)data.errorlog_struct[i].error_struct.sector_count, + (int)data.errorlog_struct[i].error_struct.sector_number, + (int)data.errorlog_struct[i].error_struct.cylinder_low, + (int)data.errorlog_struct[i].error_struct.cylinder_high, + (int)data.errorlog_struct[i].error_struct.drive_head, + (int)data.errorlog_struct[i].error_struct.status); pout("Sequence of commands leading to the command that caused the error were:\n"); pout("DCR FR SC SN CL CH D/H CR Timestamp\n"); for ( j = 4; j >= 0; j--){ @@ -587,17 +572,17 @@ 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", - thiscommand->devicecontrolreg, - thiscommand->featuresreg, - thiscommand->sector_count, - thiscommand->sector_number, - thiscommand->cylinder_low, - thiscommand->cylinder_high, - thiscommand->drive_head, - thiscommand->commandreg, - (unsigned int)(thiscommand->timestamp / 1000), - (unsigned int)(thiscommand->timestamp % 1000)); + pout(" %02x %02x %02x %02x %02x %02x %02x %02x %d.%03d\n", + (int)thiscommand->devicecontrolreg, + (int)thiscommand->featuresreg, + (int)thiscommand->sector_count, + (int)thiscommand->sector_number, + (int)thiscommand->cylinder_low, + (int)thiscommand->cylinder_high, + (int)thiscommand->drive_head, + (int)thiscommand->commandreg, + (unsigned int)(thiscommand->timestamp / 1000U), + (unsigned int)(thiscommand->timestamp % 1000U)); } pout("\n"); } @@ -615,8 +600,8 @@ int ataPrintSmartSelfTestlog(struct ata_smart_selftestlog data,int allentries){ int retval=0; if (allentries) - pout("SMART Self-test log, version number %u\n",data.revnumber); - if (data.revnumber!=0x01 && allentries) + pout("SMART Self-test log, version number %d\n",(int)data.revnumber); + if ((data.revnumber!=0x0001) && allentries) pout("Warning - structure revision number does not match spec!\n"); if (data.mostrecenttest==0){ if (allentries) @@ -686,8 +671,8 @@ int ataPrintSmartSelfTestlog(struct ata_smart_selftestlog data,int allentries){ } if (allentries || errorfound) - pout("#%2d %s %s %s %8u %s\n",21-i,msgtest,msgstat, - percent,log->timestamp,firstlba); + pout("#%2d %s %s %s %8d %s\n",21-i,msgtest,msgstat, + percent,(int)log->timestamp,firstlba); } } if (!allentries && retval) @@ -705,7 +690,7 @@ void ataPseudoCheckSmart ( struct ata_smart_values data, data.vendor_attributes[i].status.flag.prefailure && (data.vendor_attributes[i].current <= thresholds.thres_entries[i].threshold) && (thresholds.thres_entries[i].threshold != 0xFE)){ - pout("Attribute ID %i Failed\n",data.vendor_attributes[i].id); + pout("Attribute ID %d Failed\n",(int)data.vendor_attributes[i].id); failed = 1; } } @@ -782,7 +767,7 @@ int ataPrintMain (int fd){ // From here on, every command requires that SMART be enabled... if (!ataDoesSmartWork(fd)) { - pout("SMART Disabled. Use option -%c to enable it.\n", SMARTENABLE ); + pout("SMART Disabled. Use option -%c to enable it.\n", (int)SMARTENABLE ); return returnval; } @@ -792,7 +777,7 @@ int ataPrintMain (int fd){ pout( "Smartctl: SMART Disable Failed.\n\n"); returnval|=FAILSMART; } - pout("SMART Disabled. Use option -%c to enable it.\n",SMARTENABLE); + pout("SMART Disabled. Use option -%c to enable it.\n",(int)SMARTENABLE); return returnval; } @@ -966,10 +951,10 @@ 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", - timewait, con->testcase==OFFLINE_FULL_SCAN?"seconds":"minutes"); + (int)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", (int)SMARTSELFTESTABORT); } return returnval; } diff --git a/sm5/smartctl.c b/sm5/smartctl.c index 6e917dc60efb0b1e5fe10370493ac278dd4ded06..989da0ed1fbfcf949b78f631e933f706d9d9b154 100644 --- a/sm5/smartctl.c +++ b/sm5/smartctl.c @@ -39,7 +39,7 @@ #include "extern.h" extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; -const char* CVSid5="$Id: smartctl.c,v 1.23 2002/10/29 14:19:11 ballen4705 Exp $" +const char* CVSid5="$Id: smartctl.c,v 1.24 2002/10/30 06:02:40 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6; // This is a block containing all the "control variables". We declare @@ -48,7 +48,7 @@ atamainctrl *con=NULL; void printslogan(){ pout("smartctl version %d.%d-%d Copyright (C) 2002 Bruce Allen\n", - RELEASE_MAJOR,RELEASE_MINOR,SMARTMONTOOLS_VERSION); + (int)RELEASE_MAJOR, (int)RELEASE_MINOR, (int)SMARTMONTOOLS_VERSION); pout("Home page is %s\n\n",PROJECTHOME); return; } @@ -219,7 +219,7 @@ void ParseOpts (int argc, char** argv){ con->veryquietmode=FALSE; printslogan(); if (optopt){ - pout("=======> UNRECOGNIZED OPTION: %c <=======\n\n",optopt); + pout("=======> UNRECOGNIZED OPTION: %c <=======\n\n",(int)optopt); Usage(); exit(FAILCMD); } @@ -253,7 +253,14 @@ void ParseOpts (int argc, char** argv){ } -// Printing function (controlled by global con->veryquietmode) +// Printing function (controlled by global con->veryquietmode) + +// [From GLIBC Manual: Since the prototype doesn't specify types for +// optional arguments, in a call to a variadic function the default +// argument promotions are performed on the optional argument +// values. This means the objects of type char or short int (whether +// signed or not) are promoted to either int or unsigned int, as +// appropriate.] void pout(char *fmt, ...){ va_list ap; diff --git a/sm5/smartctl.cpp b/sm5/smartctl.cpp index 7f0dfbe8eba3555e2911b1781f011ded921d44a2..e86cb40b0568518e3dc9ffbf65a963027932caf5 100644 --- a/sm5/smartctl.cpp +++ b/sm5/smartctl.cpp @@ -39,7 +39,7 @@ #include "extern.h" extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; -const char* CVSid5="$Id: smartctl.cpp,v 1.23 2002/10/29 14:19:11 ballen4705 Exp $" +const char* CVSid5="$Id: smartctl.cpp,v 1.24 2002/10/30 06:02:40 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6; // This is a block containing all the "control variables". We declare @@ -48,7 +48,7 @@ atamainctrl *con=NULL; void printslogan(){ pout("smartctl version %d.%d-%d Copyright (C) 2002 Bruce Allen\n", - RELEASE_MAJOR,RELEASE_MINOR,SMARTMONTOOLS_VERSION); + (int)RELEASE_MAJOR, (int)RELEASE_MINOR, (int)SMARTMONTOOLS_VERSION); pout("Home page is %s\n\n",PROJECTHOME); return; } @@ -219,7 +219,7 @@ void ParseOpts (int argc, char** argv){ con->veryquietmode=FALSE; printslogan(); if (optopt){ - pout("=======> UNRECOGNIZED OPTION: %c <=======\n\n",optopt); + pout("=======> UNRECOGNIZED OPTION: %c <=======\n\n",(int)optopt); Usage(); exit(FAILCMD); } @@ -253,7 +253,14 @@ void ParseOpts (int argc, char** argv){ } -// Printing function (controlled by global con->veryquietmode) +// Printing function (controlled by global con->veryquietmode) + +// [From GLIBC Manual: Since the prototype doesn't specify types for +// optional arguments, in a call to a variadic function the default +// argument promotions are performed on the optional argument +// values. This means the objects of type char or short int (whether +// signed or not) are promoted to either int or unsigned int, as +// appropriate.] void pout(char *fmt, ...){ va_list ap; diff --git a/sm5/smartd.c b/sm5/smartd.c index 12c7d06ee88e9c2df66d5cec99f9141a45795b3e..fcce22da6ba95862b61f78366799c522bb3db04e 100644 --- a/sm5/smartd.c +++ b/sm5/smartd.c @@ -44,7 +44,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.c,v 1.45 2002/10/29 23:09:29 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.c,v 1.46 2002/10/30 06:02:40 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -64,6 +64,13 @@ unsigned char debugmode = FALSE; unsigned char printcopyleft = FALSE; // This function prints either to stdout or to the syslog as needed + +// [From GLIBC Manual: Since the prototype doesn't specify types for +// optional arguments, in a call to a variadic function the default +// argument promotions are performed on the optional argument +// values. This means the objects of type char or short int (whether +// signed or not) are promoted to either int or unsigned int, as +// appropriate.] void printout(int priority,char *fmt, ...){ va_list ap; // initialize variable argument list @@ -98,7 +105,7 @@ void huphandler(int sig){ // simple signal handler to print goodby message to syslog void sighandler(int sig){ printout(LOG_CRIT,"smartd received signal %d: %s\n", - sig,strsignal(sig)); + sig, strsignal(sig)); exit(1); } @@ -155,7 +162,7 @@ int daemon_init(void){ // Prints header identifying version of code and home void printhead(){ printout(LOG_INFO,"smartd version %d.%d-%d - S.M.A.R.T. Daemon.\n", - RELEASE_MAJOR, RELEASE_MINOR, SMARTMONTOOLS_VERSION); + (int)RELEASE_MAJOR, (int)RELEASE_MINOR, (int)SMARTMONTOOLS_VERSION); printout(LOG_INFO,"Home page is %s\n\n",PROJECTHOME); return; } @@ -188,8 +195,8 @@ return; void Usage (void){ printout(LOG_INFO,"usage: smartd -[opts] \n\n"); printout(LOG_INFO,"Command Line Options:\n"); - printout(LOG_INFO," %c Start smartd in debug Mode\n",DEBUGMODE); - printout(LOG_INFO," %c Print License, Copyright, and version information\n\n",PRINTCOPYLEFT); + printout(LOG_INFO," %c Start smartd in debug Mode\n",(int)DEBUGMODE); + printout(LOG_INFO," %c Print License, Copyright, and version information\n\n",(int)PRINTCOPYLEFT); printout(LOG_INFO,"Optional configuration file: %s\n",CONFIGFILE); Directives(); } @@ -214,7 +221,7 @@ int closedevice(int fd, char *name){ if (errno<sys_nerr) printout(LOG_INFO,"Device: %s, %s, close(%d) failed\n", name, sys_errlist[errno], fd); else - printout(LOG_INFO,"Device: %s, close(%d) failed\n",name,fd); + printout(LOG_INFO,"Device: %s, close(%d) failed\n",name, fd); return 1; } // device sucessfully closed @@ -235,7 +242,7 @@ int ataerrorcount(int fd, char *name){ } // returns <0 if problem -char selftesterrorcount(int fd, char *name){ +int selftesterrorcount(int fd, char *name){ struct ata_smart_selftestlog log; if (-1==ataReadSelfTestLog(fd,&log)){ @@ -244,7 +251,7 @@ char selftesterrorcount(int fd, char *name){ } // return current number of self-test errors - return (char)ataPrintSmartSelfTestlog(log,0); + return ataPrintSmartSelfTestlog(log,0); } @@ -305,7 +312,7 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){ // capability check: self-test-log if (cfg->selftest){ - char val=selftesterrorcount(fd, device); + int val=selftesterrorcount(fd, device); if (val>=0) cfg->selflogcount=val; else @@ -331,7 +338,7 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){ // Do we still have entries available? if (numatadevices>=MAXATADEVICES){ printout(LOG_CRIT,"smartd has found more than MAXATADEVICES=%d ATA devices.\n" - "Recompile code from " PROJECTHOME " with larger MAXATADEVICES\n",numatadevices); + "Recompile code from " PROJECTHOME " with larger MAXATADEVICES\n",(int)numatadevices); exit(1); } @@ -387,7 +394,7 @@ int scsidevicescan(scsidevices_t *devices, char *device){ // Device exists, and does SMART. Add to list if (numscsidevices>=MAXSCSIDEVICES){ printout(LOG_CRIT,"smartd has found more than MAXSCSIDEVICES=%d SCSI devices.\n" - "Recompile code from " PROJECTHOME " with larger MAXSCSIDEVICES\n",numscsidevices); + "Recompile code from " PROJECTHOME " with larger MAXSCSIDEVICES\n",(int)numscsidevices); exit(1); } @@ -452,8 +459,8 @@ int ataCompareSmartValues2(struct ata_smart_values *new, // 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); + printout(LOG_INFO,"Device: %s, same Attribute has different ID numbers: %d = %d = %d\n", + name, (int)now->id, (int)was->id, (int)thre->id); return 0; } @@ -568,13 +575,13 @@ int ataCheckDevice(atadevices_t *drive){ // prefailure attribute if (cfg->prefail && prefail) - printout(LOG_INFO, "Device: %s, SMART Prefailure Attribute: %s changed from %i to %i\n", - name, loc, oldval, newval); + printout(LOG_INFO, "Device: %s, SMART Prefailure Attribute: %s changed from %d to %d\n", + name, loc, (int)oldval, (int)newval); // usage attribute if (cfg->usage && !prefail) - printout(LOG_INFO, "Device: %s, SMART Usage Attribute: %s changed from %i to %i\n", - name, loc, oldval, newval); + printout(LOG_INFO, "Device: %s, SMART Usage Attribute: %s changed from %d to %d\n", + name, loc, (int)oldval, (int)newval); } } // endof block tracking usage or prefailure } // end of loop over attributes @@ -586,11 +593,11 @@ int ataCheckDevice(atadevices_t *drive){ // check if number of selftest errors has increased (note: may also DECREASE) if (cfg->selftest){ - char old=cfg->selflogcount; - char new=selftesterrorcount(fd, name); + unsigned char old=cfg->selflogcount; + int new=selftesterrorcount(fd, name); if (new>old){ printout(LOG_CRIT,"Device: %s, Self-Test Log error count increased from %d to %d\n", - name,old,new); + name, (int)old, new); } if (new>=0) // Needed suince self-test error count may DECREASE @@ -604,7 +611,7 @@ int ataCheckDevice(atadevices_t *drive){ int new=ataerrorcount(fd, name); if (new>old){ printout(LOG_CRIT,"Device: %s, ATA error count increased from %d to %d\n", - name,old,new); + name, old, new); } // this last line is probably not needed, count always increases if (new>=0) @@ -633,17 +640,17 @@ int scsiCheckDevice( scsidevices_t *drive){ printout(LOG_INFO, "Device: %s, failed to read SMART values\n", drive->devicename); if (returnvalue) - printout(LOG_CRIT, "Device: %s, SMART Failure: (%02x) %s\n", drive->devicename, - returnvalue, scsiSmartGetSenseCode( returnvalue) ); + printout(LOG_CRIT, "Device: %s, SMART Failure: (%d) %s\n", drive->devicename, + (int)returnvalue, scsiSmartGetSenseCode(returnvalue)); else - printout(LOG_INFO,"Device: %s, Acceptable attribute: %d\n", drive->devicename, returnvalue); + printout(LOG_INFO,"Device: %s, Acceptable attribute: %d\n", drive->devicename, (int)returnvalue); // Seems to completely ignore what capabilities were found on the // device when scanned if (currenttemp){ if ((currenttemp != drive->Temperature) && (drive->Temperature)) printout(LOG_INFO, "Device: %s, Temperature changed %d degrees to %d degrees since last reading\n", - drive->devicename, (int) (currenttemp - drive->Temperature), (unsigned int) currenttemp ); + drive->devicename, (int) (currenttemp - drive->Temperature), (int)currenttemp ); drive->Temperature = currenttemp; } closedevice(fd, drive->devicename); @@ -927,7 +934,7 @@ int parseconfigfile(){ else warn=""; printout(LOG_CRIT,"Error: line %d of file %s %sis more than %d characters.\n", - contlineno,CONFIGFILE,warn,MAXLINELEN); + (int)contlineno,CONFIGFILE,warn,(int)MAXLINELEN); exit(1); } @@ -940,7 +947,7 @@ int parseconfigfile(){ // is the total line (made of all continuation lines) too long? if (cont+len>MAXCONTLINE){ printout(LOG_CRIT,"Error: continued line %d (actual line %d) of file %s is more than %d characters.\n", - lineno,contlineno,CONFIGFILE,MAXCONTLINE); + lineno, (int)contlineno, CONFIGFILE, (int)MAXCONTLINE); exit(1); } @@ -1030,7 +1037,7 @@ int makeconfigentries(int num, char *name, int isata, int start){ int i; if (MAXENTRIES<(start+num)){ - printout(LOG_CRIT,"Error: simulated config file can have no more than %d entries\n",MAXENTRIES); + printout(LOG_CRIT,"Error: simulated config file can have no more than %d entries\n",(int)MAXENTRIES); exit(1); } diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index e9c44df0411518f213736d49cd3038c776a82416..d86b3440a3461897a167c28d8d44e25b87490e5f 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -44,7 +44,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.cpp,v 1.45 2002/10/29 23:09:29 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.cpp,v 1.46 2002/10/30 06:02:40 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -64,6 +64,13 @@ unsigned char debugmode = FALSE; unsigned char printcopyleft = FALSE; // This function prints either to stdout or to the syslog as needed + +// [From GLIBC Manual: Since the prototype doesn't specify types for +// optional arguments, in a call to a variadic function the default +// argument promotions are performed on the optional argument +// values. This means the objects of type char or short int (whether +// signed or not) are promoted to either int or unsigned int, as +// appropriate.] void printout(int priority,char *fmt, ...){ va_list ap; // initialize variable argument list @@ -98,7 +105,7 @@ void huphandler(int sig){ // simple signal handler to print goodby message to syslog void sighandler(int sig){ printout(LOG_CRIT,"smartd received signal %d: %s\n", - sig,strsignal(sig)); + sig, strsignal(sig)); exit(1); } @@ -155,7 +162,7 @@ int daemon_init(void){ // Prints header identifying version of code and home void printhead(){ printout(LOG_INFO,"smartd version %d.%d-%d - S.M.A.R.T. Daemon.\n", - RELEASE_MAJOR, RELEASE_MINOR, SMARTMONTOOLS_VERSION); + (int)RELEASE_MAJOR, (int)RELEASE_MINOR, (int)SMARTMONTOOLS_VERSION); printout(LOG_INFO,"Home page is %s\n\n",PROJECTHOME); return; } @@ -188,8 +195,8 @@ return; void Usage (void){ printout(LOG_INFO,"usage: smartd -[opts] \n\n"); printout(LOG_INFO,"Command Line Options:\n"); - printout(LOG_INFO," %c Start smartd in debug Mode\n",DEBUGMODE); - printout(LOG_INFO," %c Print License, Copyright, and version information\n\n",PRINTCOPYLEFT); + printout(LOG_INFO," %c Start smartd in debug Mode\n",(int)DEBUGMODE); + printout(LOG_INFO," %c Print License, Copyright, and version information\n\n",(int)PRINTCOPYLEFT); printout(LOG_INFO,"Optional configuration file: %s\n",CONFIGFILE); Directives(); } @@ -214,7 +221,7 @@ int closedevice(int fd, char *name){ if (errno<sys_nerr) printout(LOG_INFO,"Device: %s, %s, close(%d) failed\n", name, sys_errlist[errno], fd); else - printout(LOG_INFO,"Device: %s, close(%d) failed\n",name,fd); + printout(LOG_INFO,"Device: %s, close(%d) failed\n",name, fd); return 1; } // device sucessfully closed @@ -235,7 +242,7 @@ int ataerrorcount(int fd, char *name){ } // returns <0 if problem -char selftesterrorcount(int fd, char *name){ +int selftesterrorcount(int fd, char *name){ struct ata_smart_selftestlog log; if (-1==ataReadSelfTestLog(fd,&log)){ @@ -244,7 +251,7 @@ char selftesterrorcount(int fd, char *name){ } // return current number of self-test errors - return (char)ataPrintSmartSelfTestlog(log,0); + return ataPrintSmartSelfTestlog(log,0); } @@ -305,7 +312,7 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){ // capability check: self-test-log if (cfg->selftest){ - char val=selftesterrorcount(fd, device); + int val=selftesterrorcount(fd, device); if (val>=0) cfg->selflogcount=val; else @@ -331,7 +338,7 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){ // Do we still have entries available? if (numatadevices>=MAXATADEVICES){ printout(LOG_CRIT,"smartd has found more than MAXATADEVICES=%d ATA devices.\n" - "Recompile code from " PROJECTHOME " with larger MAXATADEVICES\n",numatadevices); + "Recompile code from " PROJECTHOME " with larger MAXATADEVICES\n",(int)numatadevices); exit(1); } @@ -387,7 +394,7 @@ int scsidevicescan(scsidevices_t *devices, char *device){ // Device exists, and does SMART. Add to list if (numscsidevices>=MAXSCSIDEVICES){ printout(LOG_CRIT,"smartd has found more than MAXSCSIDEVICES=%d SCSI devices.\n" - "Recompile code from " PROJECTHOME " with larger MAXSCSIDEVICES\n",numscsidevices); + "Recompile code from " PROJECTHOME " with larger MAXSCSIDEVICES\n",(int)numscsidevices); exit(1); } @@ -452,8 +459,8 @@ int ataCompareSmartValues2(struct ata_smart_values *new, // 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); + printout(LOG_INFO,"Device: %s, same Attribute has different ID numbers: %d = %d = %d\n", + name, (int)now->id, (int)was->id, (int)thre->id); return 0; } @@ -568,13 +575,13 @@ int ataCheckDevice(atadevices_t *drive){ // prefailure attribute if (cfg->prefail && prefail) - printout(LOG_INFO, "Device: %s, SMART Prefailure Attribute: %s changed from %i to %i\n", - name, loc, oldval, newval); + printout(LOG_INFO, "Device: %s, SMART Prefailure Attribute: %s changed from %d to %d\n", + name, loc, (int)oldval, (int)newval); // usage attribute if (cfg->usage && !prefail) - printout(LOG_INFO, "Device: %s, SMART Usage Attribute: %s changed from %i to %i\n", - name, loc, oldval, newval); + printout(LOG_INFO, "Device: %s, SMART Usage Attribute: %s changed from %d to %d\n", + name, loc, (int)oldval, (int)newval); } } // endof block tracking usage or prefailure } // end of loop over attributes @@ -586,11 +593,11 @@ int ataCheckDevice(atadevices_t *drive){ // check if number of selftest errors has increased (note: may also DECREASE) if (cfg->selftest){ - char old=cfg->selflogcount; - char new=selftesterrorcount(fd, name); + unsigned char old=cfg->selflogcount; + int new=selftesterrorcount(fd, name); if (new>old){ printout(LOG_CRIT,"Device: %s, Self-Test Log error count increased from %d to %d\n", - name,old,new); + name, (int)old, new); } if (new>=0) // Needed suince self-test error count may DECREASE @@ -604,7 +611,7 @@ int ataCheckDevice(atadevices_t *drive){ int new=ataerrorcount(fd, name); if (new>old){ printout(LOG_CRIT,"Device: %s, ATA error count increased from %d to %d\n", - name,old,new); + name, old, new); } // this last line is probably not needed, count always increases if (new>=0) @@ -633,17 +640,17 @@ int scsiCheckDevice( scsidevices_t *drive){ printout(LOG_INFO, "Device: %s, failed to read SMART values\n", drive->devicename); if (returnvalue) - printout(LOG_CRIT, "Device: %s, SMART Failure: (%02x) %s\n", drive->devicename, - returnvalue, scsiSmartGetSenseCode( returnvalue) ); + printout(LOG_CRIT, "Device: %s, SMART Failure: (%d) %s\n", drive->devicename, + (int)returnvalue, scsiSmartGetSenseCode(returnvalue)); else - printout(LOG_INFO,"Device: %s, Acceptable attribute: %d\n", drive->devicename, returnvalue); + printout(LOG_INFO,"Device: %s, Acceptable attribute: %d\n", drive->devicename, (int)returnvalue); // Seems to completely ignore what capabilities were found on the // device when scanned if (currenttemp){ if ((currenttemp != drive->Temperature) && (drive->Temperature)) printout(LOG_INFO, "Device: %s, Temperature changed %d degrees to %d degrees since last reading\n", - drive->devicename, (int) (currenttemp - drive->Temperature), (unsigned int) currenttemp ); + drive->devicename, (int) (currenttemp - drive->Temperature), (int)currenttemp ); drive->Temperature = currenttemp; } closedevice(fd, drive->devicename); @@ -927,7 +934,7 @@ int parseconfigfile(){ else warn=""; printout(LOG_CRIT,"Error: line %d of file %s %sis more than %d characters.\n", - contlineno,CONFIGFILE,warn,MAXLINELEN); + (int)contlineno,CONFIGFILE,warn,(int)MAXLINELEN); exit(1); } @@ -940,7 +947,7 @@ int parseconfigfile(){ // is the total line (made of all continuation lines) too long? if (cont+len>MAXCONTLINE){ printout(LOG_CRIT,"Error: continued line %d (actual line %d) of file %s is more than %d characters.\n", - lineno,contlineno,CONFIGFILE,MAXCONTLINE); + lineno, (int)contlineno, CONFIGFILE, (int)MAXCONTLINE); exit(1); } @@ -1030,7 +1037,7 @@ int makeconfigentries(int num, char *name, int isata, int start){ int i; if (MAXENTRIES<(start+num)){ - printout(LOG_CRIT,"Error: simulated config file can have no more than %d entries\n",MAXENTRIES); + printout(LOG_CRIT,"Error: simulated config file can have no more than %d entries\n",(int)MAXENTRIES); exit(1); } diff --git a/sm5/smartd.h b/sm5/smartd.h index c7b0f22b1d2e747a95bc25c655d247868fbc708a..79fe386a09c6ef8b07ccd8464910bbd3326b8874 100644 --- a/sm5/smartd.h +++ b/sm5/smartd.h @@ -23,7 +23,7 @@ */ #ifndef CVSID7 -#define CVSID7 "$Id: smartd.h,v 1.15 2002/10/29 23:09:29 ballen4705 Exp $\n" +#define CVSID7 "$Id: smartd.h,v 1.16 2002/10/30 06:02:40 ballen4705 Exp $\n" #endif // Configuration file @@ -102,4 +102,9 @@ typedef struct atadevices_s { } atadevices_t; +// Declare our own printing function... +void printout(int priority,char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); + + int ataCheckDevice(atadevices_t *drive); diff --git a/sm5/smartmontools.spec b/sm5/smartmontools.spec index 4cfbdb2cd6d4ed864ce92af25799d0dcfe35de69..7a928dabe1241eaa5d811969f650f52ea13cbb8f 100644 --- a/sm5/smartmontools.spec +++ b/sm5/smartmontools.spec @@ -1,4 +1,4 @@ -Release: 22 +Release: 23 Summary: SMARTmontools - for monitoring S.M.A.R.T. disks and devices Name: smartmontools Version: 5.0 @@ -18,7 +18,7 @@ Packager: Bruce Allen <smartmontools-support@lists.sourceforge.net> # http://telia.dl.sourceforge.net/sourceforge/smartmontools/smartmontools-%{version}-%{release}.tar.gz # CVS ID of this file is: -# $Id: smartmontools.spec,v 1.33 2002/10/29 23:18:30 ballen4705 Exp $ +# $Id: smartmontools.spec,v 1.34 2002/10/30 06:02:40 ballen4705 Exp $ # Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> # Home page: http://smartmontools.sourceforge.net @@ -113,6 +113,17 @@ fi %define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`) %changelog * Wed Oct 29 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> +- Because of reported problems with GCC 3.2 compile, I have gone + thorough the code and explicitly changed all print format + parameters to correspond EXACTLY to int unless they have to be + promoted to long longs. To quote from the glibc bible: [From + GLIBC Manual: Since the prototype doesn't specify types for + optional arguments, in a call to a variadic function the default + argument promotions are performed on the optional argument + values. This means the objects of type char or short int (whether + signed or not) are promoted to either int or unsigned int, as + required. +* Wed Oct 29 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> - smartd, smartctl now warn if they find an attribute whose ID number does not match between Data and Threshold structures. - Fixed nasty bug which led to wrong number of arguments for a