diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG index ed48e14c7761372a2db64a1151a677bc1c038a6f..fc32ae97ddffd3b484ab291d998bb12be9cabd0e 100644 --- a/smartmontools/CHANGELOG +++ b/smartmontools/CHANGELOG @@ -43,6 +43,9 @@ NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [CF] Replace some 'EXIT(status)' calls by 'return status'. + Remove unnecessary casts from 'nonempty()' calls. + [CF] Windows: Set ata_device::ata_identify_is_cached() return value according to I/O-control actually used. diff --git a/smartmontools/ataprint.cpp b/smartmontools/ataprint.cpp index 889a7d278391eedd09a5556b156faaecddcee4d7..c578d873c267cfe799c1daaf75bb8bb497993b81 100644 --- a/smartmontools/ataprint.cpp +++ b/smartmontools/ataprint.cpp @@ -1172,7 +1172,7 @@ static int PrintSmartErrorlog(const ata_smart_errorlog *data, const ata_smart_errorlog_error_struct * summary = &(elog->error_struct); // Spec says: unused error log structures shall be zero filled - if (nonempty((unsigned char*)elog,sizeof(*elog))){ + if (nonempty(elog, sizeof(*elog))){ // Table 57 of T13/1532D Volume 1 Revision 3 const char *msgstate = get_error_log_state_desc(summary->state); int days = (int)summary->timestamp/24; @@ -1208,7 +1208,7 @@ static int PrintSmartErrorlog(const ata_smart_errorlog *data, const ata_smart_errorlog_command_struct * thiscommand = elog->commands+j; // Spec says: unused data command structures shall be zero filled - if (nonempty((unsigned char*)thiscommand,sizeof(*thiscommand))) { + if (nonempty(thiscommand, sizeof(*thiscommand))) { char timestring[32]; // Convert integer milliseconds to a text-format string @@ -1776,7 +1776,7 @@ int ataPrintMain (ata_device * device, const ata_print_options & options) // If requested, show which presets would be used for this drive and exit. if (options.show_presets) { show_presets(&drive, options.fix_swapped_id); - EXIT(0); + return 0; } // Use preset vendor attribute options unless user has requested otherwise. diff --git a/smartmontools/os_freebsd.cpp b/smartmontools/os_freebsd.cpp index 54c62786146c60bdeddba98860557a962aa50aa4..5d114c2feeac33cc6e33bb1f791bd2f9cbc59790 100644 --- a/smartmontools/os_freebsd.cpp +++ b/smartmontools/os_freebsd.cpp @@ -3,7 +3,7 @@ * * Home page of code is: http://smartmontools.sourceforge.net * - * Copyright (C) 2003-8 Eduard Martinescu <smartmontools-support@lists.sourceforge.net> + * Copyright (C) 2003-10 Eduard Martinescu <smartmontools-support@lists.sourceforge.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -702,7 +702,7 @@ int freebsd_escalade_device::ata_command_interface(smart_command_set command, in *data=*(char *)&(ata->sector_count); // look for nonexistent devices/ports - if (command==IDENTIFY && !nonempty((unsigned char *)data, 512)) { + if (command==IDENTIFY && !nonempty(data, 512)) { errno=ENODEV; return -1; } diff --git a/smartmontools/os_linux.cpp b/smartmontools/os_linux.cpp index 2ec4b616dbac336950cabeee7073e3a3a8f9207e..bcd5e2a560509937716dc59253c24e78c173245f 100644 --- a/smartmontools/os_linux.cpp +++ b/smartmontools/os_linux.cpp @@ -3,12 +3,12 @@ * * Home page of code is: http://smartmontools.sourceforge.net * - * Copyright (C) 2003-8 Bruce Allen <smartmontools-support@lists.sourceforge.net> - * Copyright (C) 2003-8 Doug Gilbert <dougg@torque.net> - * Copyright (C) 2008 Hank Wu <hank@areca.com.tw> - * Copyright (C) 2008 Oliver Bock <brevilo@users.sourceforge.net> - * Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net> - * Copyright (C) 2008 Jordan Hargrave <jordan_hargrave@dell.com> + * Copyright (C) 2003-10 Bruce Allen <smartmontools-support@lists.sourceforge.net> + * Copyright (C) 2003-10 Doug Gilbert <dougg@torque.net> + * Copyright (C) 2008 Hank Wu <hank@areca.com.tw> + * Copyright (C) 2008 Oliver Bock <brevilo@users.sourceforge.net> + * Copyright (C) 2008-10 Christian Franke <smartmontools-support@lists.sourceforge.net> + * Copyright (C) 2008 Jordan Hargrave <jordan_hargrave@dell.com> * * Parts of this file are derived from code that was * @@ -1622,7 +1622,7 @@ bool linux_escalade_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out // look for nonexistent devices/ports if ( in.in_regs.command == ATA_IDENTIFY_DEVICE - && !nonempty((unsigned char *)in.buffer, in.size)) { + && !nonempty(in.buffer, in.size)) { return set_err(ENODEV, "No drive on port %d", m_disknum); } diff --git a/smartmontools/os_win32.cpp b/smartmontools/os_win32.cpp index ab4aad2cbf86769c78fade49966518854e8d334f..23c11d869319e0a212101972c70484f5b6026be8 100644 --- a/smartmontools/os_win32.cpp +++ b/smartmontools/os_win32.cpp @@ -815,7 +815,7 @@ static int smart_ioctl(HANDLE hdevice, int drive, IDEREGS * regs, char * data, u if (datasize) memcpy(data, outpar->bBuffer, 512); else if (regs->bFeaturesReg == ATA_SMART_STATUS) { - if (nonempty(const_cast<unsigned char *>(outpar->bBuffer), sizeof(IDEREGS))) + if (nonempty(outpar->bBuffer, sizeof(IDEREGS))) *regs = *(const IDEREGS *)(outpar->bBuffer); else { // Workaround for driver not returning regs if (con->reportataioctl) diff --git a/smartmontools/smartd.cpp b/smartmontools/smartd.cpp index 85044e7f5dec82c2596c0acce90c9c5711741594..16b6db5bbec52bba09849ea68733338151929014 100644 --- a/smartmontools/smartd.cpp +++ b/smartmontools/smartd.cpp @@ -1,10 +1,10 @@ /* * Home page of code is: http://smartmontools.sourceforge.net * - * Copyright (C) 2002-9 Bruce Allen <smartmontools-support@lists.sourceforge.net> - * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org> - * Copyright (C) 2008 Oliver Bock <brevilo@users.sourceforge.net> - * Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net> + * Copyright (C) 2002-10 Bruce Allen <smartmontools-support@lists.sourceforge.net> + * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org> + * Copyright (C) 2008 Oliver Bock <brevilo@users.sourceforge.net> + * Copyright (C) 2008-10 Christian Franke <smartmontools-support@lists.sourceforge.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -4293,8 +4293,7 @@ int main_worker(int argc, char **argv) } else { // exit with configuration file error status - int status = (entries==-3 ? EXIT_READCONF : entries==-2 ? EXIT_NOCONF : EXIT_BADCONF); - EXIT(status); + return (entries==-3 ? EXIT_READCONF : entries==-2 ? EXIT_NOCONF : EXIT_BADCONF); } } @@ -4310,13 +4309,13 @@ int main_worker(int argc, char **argv) } else { PrintOut(LOG_INFO,"Unable to monitor any SMART enabled devices. Try debug (-d) option. Exiting...\n"); - EXIT(EXIT_NODEV); + return EXIT_NODEV; } if (quit==4) { // user has asked to print test schedule PrintTestSchedule(configs, states, devices); - EXIT(0); + return 0; } // reset signal @@ -4343,7 +4342,7 @@ int main_worker(int argc, char **argv) if (quit==3) { PrintOut(LOG_INFO,"Started with '-q onecheck' option. All devices sucessfully checked once.\n" "smartd is exiting (exit status 0)\n"); - EXIT(0); + return 0; } // fork into background if needed