diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog index ce4d9d4ebbbb95766ab29b35b44a982907ff7934..9afd2c07ab231521f1783238902897fc6436e8f3 100644 --- a/smartmontools/ChangeLog +++ b/smartmontools/ChangeLog @@ -1,5 +1,12 @@ $Id$ +2020-02-25 Christian Franke <franke@computer.org> + + Silence some warnings from g++ 9.2: + atacmds.cpp: -Waddress-of-packed-member. + os_win32.cpp: -Wcast-function-type. + smartd.cpp: -Wformat-truncation. + 2020-02-25 Fabrice Fontaine <fontaine.fabrice@gmail.com> configure.ac: fix stack-protector detection. diff --git a/smartmontools/atacmds.cpp b/smartmontools/atacmds.cpp index 443db415ef0974aba4f0584729e40aec725bb2e9..64ea882b9dcc3be9587c2dfbbe32bda0baa70d1a 100644 --- a/smartmontools/atacmds.cpp +++ b/smartmontools/atacmds.cpp @@ -4,7 +4,7 @@ * Home page of code is: https://www.smartmontools.org * * Copyright (C) 2002-11 Bruce Allen - * Copyright (C) 2008-19 Christian Franke + * Copyright (C) 2008-20 Christian Franke * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org> * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org> * @@ -819,9 +819,6 @@ bool ata_set_features(ata_device * device, unsigned char features, int ata_read_identity(ata_device * device, ata_identify_device * buf, bool fix_swapped_id, unsigned char * raw_buf /* = 0 */) { - unsigned short *rawshort=(unsigned short *)buf; - unsigned char *rawbyte =(unsigned char *)buf; - // See if device responds either to IDENTIFY DEVICE or IDENTIFY // PACKET DEVICE bool packet = false; @@ -849,6 +846,11 @@ int ata_read_identity(ata_device * device, ata_identify_device * buf, bool fix_s if (raw_buf) memcpy(raw_buf, buf, sizeof(*buf)); + // If there is a checksum there, validate it + unsigned char * rawbyte = (unsigned char *)buf; + if (rawbyte[512-2] == 0xa5 && checksum(rawbyte)) + checksumwarning("Drive Identity Structure"); + // if machine is big-endian, swap byte order as needed if (isbigendian()){ // swap various capability words that are needed @@ -856,15 +858,11 @@ int ata_read_identity(ata_device * device, ata_identify_device * buf, bool fix_s for (i=0; i<33; i++) swap2((char *)(buf->words047_079+i)); for (i=80; i<=87; i++) - swap2((char *)(rawshort+i)); + swap2((char *)(rawbyte+2*i)); for (i=0; i<168; i++) swap2((char *)(buf->words088_255+i)); } - // If there is a checksum there, validate it - if ((rawshort[255] & 0x00ff) == 0x00a5 && checksum(rawbyte)) - checksumwarning("Drive Identity Structure"); - // AT Attachment 8 - ATA/ATAPI Command Set (ATA8-ACS) // T13/1699-D Revision 6a (Final Draft), September 6, 2008. // Sections 7.16.7 and 7.17.6: diff --git a/smartmontools/os_win32.cpp b/smartmontools/os_win32.cpp index 418ee2761c82e5370cc0340bc5813989d4173685..810acb32857f7eabc34afb74477b3467b328df58 100644 --- a/smartmontools/os_win32.cpp +++ b/smartmontools/os_win32.cpp @@ -3,7 +3,7 @@ * * Home page of code is: https://www.smartmontools.org * - * Copyright (C) 2004-19 Christian Franke + * Copyright (C) 2004-20 Christian Franke * * Original AACRaid code: * Copyright (C) 2015 Nidhi Malhotra <nidhi.malhotra@pmcs.com> @@ -4033,7 +4033,7 @@ private: static bool is_wow64() { BOOL (WINAPI * IsWow64Process_p)(HANDLE, PBOOL) = - (BOOL (WINAPI *)(HANDLE, PBOOL)) + (BOOL (WINAPI *)(HANDLE, PBOOL))(void *) GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process"); if (!IsWow64Process_p) return false; @@ -4058,7 +4058,7 @@ std::string win_smart_interface::get_os_version_str() // Starting with Windows 8.1, GetVersionEx() does no longer report the // actual OS version. RtlGetVersion() is not affected. LONG /*NTSTATUS*/ (WINAPI /*NTAPI*/ * RtlGetVersion_p)(LPOSVERSIONINFOEXW) = - (LONG (WINAPI *)(LPOSVERSIONINFOEXW)) + (LONG (WINAPI *)(LPOSVERSIONINFOEXW))(void *) GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlGetVersion"); OSVERSIONINFOEXW vi; memset(&vi, 0, sizeof(vi)); @@ -4761,7 +4761,8 @@ void smart_interface::init() { // Remove "." from DLL search path if supported // to prevent DLL preloading attacks - BOOL (WINAPI * SetDllDirectoryA_p)(LPCSTR) = (BOOL (WINAPI *)(LPCSTR)) + BOOL (WINAPI * SetDllDirectoryA_p)(LPCSTR) = + (BOOL (WINAPI *)(LPCSTR))(void *) GetProcAddress(GetModuleHandleA("kernel32.dll"), "SetDllDirectoryA"); if (SetDllDirectoryA_p) SetDllDirectoryA_p(""); diff --git a/smartmontools/smartd.cpp b/smartmontools/smartd.cpp index 1a9a6dd8d5f3fbc525b85dd472008ea6f9597889..7c356486f6d690206285aeb208b24f026fcc9a13 100644 --- a/smartmontools/smartd.cpp +++ b/smartmontools/smartd.cpp @@ -2,7 +2,7 @@ * Home page of code is: https://www.smartmontools.org * * Copyright (C) 2002-11 Bruce Allen - * Copyright (C) 2008-19 Christian Franke + * Copyright (C) 2008-20 Christian Franke * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org> * Copyright (C) 2008 Oliver Bock <brevilo@users.sourceforge.net> * @@ -1941,7 +1941,7 @@ static int ATADeviceScan(dev_config & cfg, dev_state & state, ata_device * atade state.num_sectors = sizes.sectors; cfg.dev_rpm = ata_get_rotation_rate(&drive); - char wwn[30]; wwn[0] = 0; + char wwn[64]; wwn[0] = 0; unsigned oui = 0; uint64_t unique_id = 0; int naa = ata_get_wwn(&drive, oui, unique_id); if (naa >= 0) @@ -2902,7 +2902,7 @@ static char next_scheduled_test(const dev_config & cfg, dev_state & state, bool default: continue; } // Try match of "T/MM/DD/d/HH" - char pattern[16]; + char pattern[64]; snprintf(pattern, sizeof(pattern), "%c/%02d/%02d/%1d/%02d", test_type_chars[i], tms->tm_mon+1, tms->tm_mday, weekday, tms->tm_hour); if (cfg.test_regex.full_match(pattern)) {