From 0b4ac35bc97d8c47195ca655a23d44679e07e620 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Fri, 16 Dec 2016 20:38:57 +0100 Subject: [PATCH] Tune some MSVC warnings. --- .appveyor.yml | 2 +- src/conf.h | 5 +++++ src/p_lx_elf.cpp | 2 +- src/p_mach.cpp | 5 ++--- src/p_mach_enum.h | 3 ++- src/p_w64pep.cpp | 2 +- src/pefile.cpp | 8 ++++---- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 47d0ff19..4a5e7ebb 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -19,7 +19,7 @@ environment: init: - git config --global core.autocrlf input - - where bash & where cat & where curl & where file & where git & where gzip & where readlink & where sed & where sha256sum & where tar + - where bash & where cat & where cp & where curl & where file & where git & where gzip & where mkdir & where mv & where readlink & where rm & where rmdir & where sed & where sha256sum & where tar # - bash --version & git --version & sed --version & tar --version - git --version & bash --version # - dir "c:\Program Files\Git\usr\bin" diff --git a/src/conf.h b/src/conf.h index 1b146dff..6462dc69 100644 --- a/src/conf.h +++ b/src/conf.h @@ -59,7 +59,12 @@ ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 255) // -funsigned-char ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char #if (ACC_CC_MSC) +# pragma warning(error: 4127) +# pragma warning(error: 4146) # pragma warning(error: 4319) +# pragma warning(error: 4805) +# pragma warning(disable: 4244) // -Wconversion +# pragma warning(disable: 4267) // -Wconversion #endif // FIXME - quick hack for arm-wince-gcc-3.4 (Debian pocketpc-*.deb packages) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index e940fc69..543830a9 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -3373,7 +3373,7 @@ void PackLinuxElf64::unpack(OutputFile *fo) } } bool const is_shlib = 0; // XXX: THIS IS BROKEN; see 32-bit ::unpack - if (is_shlib + if __acc_cte(is_shlib || ((unsigned)(get_te64(&ehdri.e_entry) - load_va) + up4(lsize) + ph.getPackHeaderSize() + sizeof(overlay_offset)) < up4(file_size)) { diff --git a/src/p_mach.cpp b/src/p_mach.cpp index c517b52a..4f52fc46 100644 --- a/src/p_mach.cpp +++ b/src/p_mach.cpp @@ -563,12 +563,11 @@ PackMachBase::compare_segment_command(void const *const aa, void const *const template void PackMachBase::pack4(OutputFile *fo, Filter &ft) // append PackHeader { - Mach_main_command cmdMAIN; // offset of p_info in compressed file overlay_offset = sizeof(mhdro) + sizeof(segZERO) + sizeof(segXHDR) + sizeof(secXHDR) + sizeof(segTEXT) + sizeof(secTEXT) - + sizeof(cmdUUID) + sizeof(cmdSRCVER) + sizeof(cmdVERMIN) + sizeof(cmdMAIN) + + sizeof(cmdUUID) + sizeof(cmdSRCVER) + sizeof(cmdVERMIN) + sizeof(Mach_main_command) + sizeof(Mach_dyld_info_only_command) + sizeof(Mach_dysymtab_command) + sizeof(Mach_load_dylinker_command) + sizeof(Mach_load_dylib_command) + sizeof(Mach_function_starts_command) + sizeof(Mach_data_in_code_command) @@ -1377,7 +1376,7 @@ void PackMachBase::pack1(OutputFile *const fo, Filter &/*ft*/) // generate e segZERO.cmdsize = sizeof(segZERO); strncpy((char *)segZERO.segname, "__PAGEZERO", sizeof(segZERO.segname)); segZERO.vmsize = PAGE_SIZE; - if (sizeof(segZERO.vmsize) == 8 + if __acc_cte(sizeof(segZERO.vmsize) == 8 && mhdro.filetype == Mach_header::MH_EXECUTE && mhdro.cputype == Mach_header::CPU_TYPE_X86_64) { segZERO.vmsize <<= 20; // (1ul<<32) diff --git a/src/p_mach_enum.h b/src/p_mach_enum.h index 8bf15968..3941bc2f 100644 --- a/src/p_mach_enum.h +++ b/src/p_mach_enum.h @@ -123,8 +123,9 @@ S_16BYTE_LITERALS, S_DTRACE_DOF }; + static const unsigned S_ATTR_PURE_INSTRUCTIONS = 0x80000000; enum { // section flags (high 24 bits) - S_ATTR_PURE_INSTRUCTIONS = 0x80000000, + //S_ATTR_PURE_INSTRUCTIONS = 0x80000000, S_ATTR_NO_TOC = 0x40000000, S_ATTR_STRIP_STATIC_SYMS = 0x20000000, S_ATTR_NO_DEAD_STRIP = 0x10000000, diff --git a/src/p_w64pep.cpp b/src/p_w64pep.cpp index 3ecc1067..26c548dc 100644 --- a/src/p_w64pep.cpp +++ b/src/p_w64pep.cpp @@ -142,7 +142,7 @@ void PackW64Pep::buildLoader(const Filter *ft) "RELOC64J", NULL ); - if (0) + if __acc_cte(0) { addLoader(big_relocs&6 ? "PERLOHI0" : "", big_relocs&4 ? "PERELLO0" : "", diff --git a/src/pefile.cpp b/src/pefile.cpp index 77f06d92..bebdb511 100644 --- a/src/pefile.cpp +++ b/src/pefile.cpp @@ -393,7 +393,7 @@ void PeFile32::processRelocs() // pass1 for (ic = 1; ic <= 3; ic++) { qsort(fix[ic], xcounts[ic], 4, le32_compare); - unsigned prev = ~0; + unsigned prev = ~0u; unsigned jc = 0; for (unsigned kc = 0; kc < xcounts[ic]; kc++) if (fix[ic][kc] != prev) @@ -491,7 +491,7 @@ void PeFile64::processRelocs() // pass1 for (ic = 1; ic <= 15; ic++) { qsort(fix[ic], xcounts[ic], 4, le32_compare); - unsigned prev = ~0; + unsigned prev = ~0u; unsigned jc = 0; for (unsigned kc = 0; kc < xcounts[ic]; kc++) if (fix[ic][kc] != prev) @@ -1341,7 +1341,7 @@ void PeFile::processTls2(Reloc *rel,const Interval *iv,unsigned newaddr, return; // add new relocation entries - if (tls_handler_offset_reloc > 0) + if __acc_cte(tls_handler_offset_reloc > 0) rel->add(tls_handler_offset + tls_handler_offset_reloc, reloc_type); unsigned ic; @@ -1808,7 +1808,7 @@ static bool match(unsigned itype, const unsigned char *ntype, }; // FIXME this comparison is not too exact - while (1) + for (;;) { char const *delim1 = strchr(keep, '/'); char const *delim2 = strchr(keep, ',');