From 39d6b904472abcf262e61f2ab44ee33c87e87500 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sat, 4 Jun 2016 17:10:33 +0100 Subject: [PATCH] [misc] fixes for Clang/C2 compilation support --- src/badblocks.c | 4 ++-- src/checksum.c | 8 ++++---- src/dos.c | 4 ---- src/format.c | 7 +++++++ src/libcdio/driver/_cdio_stdio.c | 5 +++-- src/libcdio/driver/_cdio_stream.c | 5 +++-- src/libcdio/driver/ds.c | 5 +++-- src/libcdio/driver/sector.c | 2 +- src/libcdio/iso9660/iso9660.c | 2 +- src/missing.h | 4 +++- src/rufus.c | 2 +- src/rufus.rc | 10 +++++----- src/vhd.c | 2 +- 13 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/badblocks.c b/src/badblocks.c index be03dc8b..4e4386b5 100644 --- a/src/badblocks.c +++ b/src/badblocks.c @@ -50,8 +50,8 @@ #include "file.h" FILE* log_fd = NULL; -static const char* abort_msg = "Too many bad blocks, aborting test\n"; -static const char* bb_prefix = "Bad Blocks: "; +static const char abort_msg[] = "Too many bad blocks, aborting test\n"; +static const char bb_prefix[] = "Bad Blocks: "; /* *From e2fsprogs/lib/ext2fs/badblocks.c diff --git a/src/checksum.c b/src/checksum.c index 714c8c1a..f01abebb 100644 --- a/src/checksum.c +++ b/src/checksum.c @@ -68,7 +68,7 @@ char sum_str[CHECKSUM_MAX][65]; uint32_t bufnum, sum_count[CHECKSUM_MAX] = { 16, 20, 32 }; HANDLE data_ready[CHECKSUM_MAX], thread_ready[CHECKSUM_MAX]; DWORD read_size[2]; -char ALIGNED(64) buffer[2][BUFFER_SIZE]; +unsigned char ALIGNED(64) buffer[2][BUFFER_SIZE]; /* * Rotate 32 bit integers by n bytes. @@ -718,7 +718,7 @@ sum_final_t *sum_final[CHECKSUM_MAX] = { md5_final, sha1_final , sha256_final }; BOOL HashFile(const unsigned type, const char* path, uint8_t* sum) { BOOL r = FALSE; - SUM_CONTEXT sum_ctx = { 0 }; + SUM_CONTEXT sum_ctx = { {0} }; HANDLE h = INVALID_HANDLE_VALUE; DWORD rs = 0; uint64_t rb; @@ -759,7 +759,7 @@ out: BOOL HashBuffer(const unsigned type, const unsigned char* buf, const size_t len, uint8_t* sum) { BOOL r = FALSE; - SUM_CONTEXT sum_ctx = { 0 }; + SUM_CONTEXT sum_ctx = { {0} }; if ((type >= CHECKSUM_MAX) || (sum == NULL)) goto out; @@ -845,7 +845,7 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM // Individual thread that computes one of MD5, SHA1 or SHA256 in parallel DWORD WINAPI IndividualSumThread(void* param) { - SUM_CONTEXT sum_ctx = { 0 }; // There's a memset in sum_init, but static analyzers still bug us + SUM_CONTEXT sum_ctx = { {0} }; // There's a memset in sum_init, but static analyzers still bug us uint32_t i = (uint32_t)(uintptr_t)param, j; sum_init[i](&sum_ctx); diff --git a/src/dos.c b/src/dos.c index db57ee01..3ac091d2 100644 --- a/src/dos.c +++ b/src/dos.c @@ -71,10 +71,6 @@ typedef struct _TIME_FIELDS { #define ARGUMENT_PRESENT(ArgumentPointer) \ ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL) -static const int YearLengths[2] = -{ - DAYSPERNORMALYEAR, DAYSPERLEAPYEAR -}; static const UCHAR MonthLengths[2][MONSPERYEAR] = { { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, diff --git a/src/format.c b/src/format.c index 6567c12e..a356a1db 100644 --- a/src/format.c +++ b/src/format.c @@ -1720,7 +1720,14 @@ DWORD WINAPI FormatThread(void* param) if (report.bb_count) { bb_msg = lmprintf(MSG_011, report.bb_count, report.num_read_errors, report.num_write_errors, report.num_corruption_errors); +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-security" +#endif fprintf(log_fd, bb_msg); +#if defined(__clang__) +#pragma clang diagnostic pop +#endif GetLocalTime(<); fprintf(log_fd, APPLICATION_NAME " bad blocks check ended on: %04d.%02d.%02d %02d:%02d:%02d\n", lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond); diff --git a/src/libcdio/driver/_cdio_stdio.c b/src/libcdio/driver/_cdio_stdio.c index 0a686934..5340b11e 100644 --- a/src/libcdio/driver/_cdio_stdio.c +++ b/src/libcdio/driver/_cdio_stdio.c @@ -88,7 +88,7 @@ static inline int _stati64_utf8(const char *path, struct _stati64 *buffer) { #define _STRINGIFY(a) #a #define STRINGIFY(a) _STRINGIFY(a) -static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.6 2008/04/22 15:29:11 karl Exp $"; +// static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.6 2008/04/22 15:29:11 karl Exp $"; #define CDIO_STDIO_BUFSIZE (128*1024) @@ -283,7 +283,8 @@ cdio_stdio_new(const char pathname[]) return new_obj; } - + + /* * Local variables: * c-file-style: "gnu" diff --git a/src/libcdio/driver/_cdio_stream.c b/src/libcdio/driver/_cdio_stream.c index f3c453c2..dd36378d 100644 --- a/src/libcdio/driver/_cdio_stream.c +++ b/src/libcdio/driver/_cdio_stream.c @@ -41,7 +41,7 @@ #include #include "_cdio_stream.h" -static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.9 2008/04/22 15:29:11 karl Exp $"; +// static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.9 2008/04/22 15:29:11 karl Exp $"; /* * DataSource implementations @@ -212,7 +212,8 @@ cdio_stream_stat(CdioDataSource_t *p_obj) return p_obj->op.stat(p_obj->user_data); } - + + /* * Local variables: * c-file-style: "gnu" diff --git a/src/libcdio/driver/ds.c b/src/libcdio/driver/ds.c index 74936bb8..28a9aed5 100644 --- a/src/libcdio/driver/ds.c +++ b/src/libcdio/driver/ds.c @@ -33,7 +33,7 @@ #include #include "cdio_assert.h" -static const char _rcsid[] = "$Id: ds.c,v 1.4 2008/04/22 15:29:12 karl Exp $"; +// static const char _rcsid[] = "$Id: ds.c,v 1.4 2008/04/22 15:29:12 karl Exp $"; struct _CdioList { @@ -243,7 +243,8 @@ _cdio_list_node_data (CdioListNode_t *p_node) /* eof */ - + + /* * Local variables: * c-file-style: "gnu" diff --git a/src/libcdio/driver/sector.c b/src/libcdio/driver/sector.c index 280365b3..c5367413 100644 --- a/src/libcdio/driver/sector.c +++ b/src/libcdio/driver/sector.c @@ -36,7 +36,7 @@ #include -static const char _rcsid[] = "$Id: sector.c,v 1.5 2005/02/06 04:20:25 rocky Exp $"; +// static const char _rcsid[] = "$Id: sector.c,v 1.5 2005/02/06 04:20:25 rocky Exp $"; /*! String of bytes used to identify the beginning of a Mode 1 or Mode 2 sector. */ diff --git a/src/libcdio/iso9660/iso9660.c b/src/libcdio/iso9660/iso9660.c index 6bdf9c5e..84fda584 100644 --- a/src/libcdio/iso9660/iso9660.c +++ b/src/libcdio/iso9660/iso9660.c @@ -119,7 +119,7 @@ localtime_r(const time_t *timer, struct tm *result) } #endif -static const char _rcsid[] = "$Id: iso9660.c,v 1.41 2008/06/25 08:01:54 rocky Exp $"; +// static const char _rcsid[] = "$Id: iso9660.c,v 1.41 2008/06/25 08:01:54 rocky Exp $"; /* Variables to hold debugger-helping enumerations */ enum iso_enum1_s iso_enums1; diff --git a/src/missing.h b/src/missing.h index f6a5ac13..3c4f6cd2 100644 --- a/src/missing.h +++ b/src/missing.h @@ -46,7 +46,7 @@ * We account for these built-in calls doing nothing if the * line has already been fetched, or if the address is invalid. */ -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) #define PREFETCH64(m) do { __builtin_prefetch(m, 0, 0); __builtin_prefetch(m+32, 0, 0); } while(0) #elif defined(_MSC_VER) #define PREFETCH64(m) do { _m_prefetch(m); _m_prefetch(m+32); } while(0) @@ -55,9 +55,11 @@ /* Read/write with endianness swap */ #if defined (_MSC_VER) && (_MSC_VER >= 1300) #include +#if !defined(__clang__) #pragma intrinsic(_byteswap_ushort) #pragma intrinsic(_byteswap_ulong) #pragma intrinsic(_byteswap_uint64) +#endif #define bswap_uint64 _byteswap_uint64 #define bswap_uint32 _byteswap_ulong #define bswap_uint16 _byteswap_ushort diff --git a/src/rufus.c b/src/rufus.c index 4b3a5a09..48ebe4d4 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -2781,7 +2781,7 @@ static BOOL IsCurrentProcessElevated(void) DWORD size; HANDLE token = INVALID_HANDLE_VALUE; TOKEN_ELEVATION te; - SID_IDENTIFIER_AUTHORITY auth = SECURITY_NT_AUTHORITY; + SID_IDENTIFIER_AUTHORITY auth = { SECURITY_NT_AUTHORITY }; PSID psid; if (ReadRegistryKey32(REGKEY_HKLM, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\EnableLUA") == 1) { diff --git a/src/rufus.rc b/src/rufus.rc index 37ff3e9c..43f8fd37 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.10.947" +CAPTION "Rufus 2.10.948" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -320,8 +320,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,10,947,0 - PRODUCTVERSION 2,10,947,0 + FILEVERSION 2,10,948,0 + PRODUCTVERSION 2,10,948,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -338,13 +338,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.10.947" + VALUE "FileVersion", "2.10.948" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.10.947" + VALUE "ProductVersion", "2.10.948" END END BLOCK "VarFileInfo" diff --git a/src/vhd.c b/src/vhd.c index d10a8c2f..3ae54dcc 100644 --- a/src/vhd.c +++ b/src/vhd.c @@ -527,7 +527,7 @@ enum WIMMessage { WIM_MSG_WARNING, // Sent when a warning message is available. WIM_MSG_CHK_PROCESS, WIM_MSG_SUCCESS = 0x00000000, - WIM_MSG_ABORT_IMAGE = 0xFFFFFFFF + WIM_MSG_ABORT_IMAGE = -1 }; #define INVALID_CALLBACK_VALUE 0xFFFFFFFF