From b6a9b0a4c967f82124a1c5b1f06b8f3828b0335f Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Wed, 31 Mar 2010 02:16:32 +0200 Subject: [PATCH] Silence some compilation warnings. --- src/conf.h | 1 + src/p_elf.h | 6 ++++-- src/p_lx_elf.cpp | 6 +++--- src/p_mach.cpp | 17 ++++++++--------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/conf.h b/src/conf.h index bd551da2..f956a217 100644 --- a/src/conf.h +++ b/src/conf.h @@ -93,6 +93,7 @@ # error "need Visual C++ 5.0 or newer" # endif # pragma warning(error: 4096) // W2: '__cdecl' must be used with '...' +# pragma warning(error: 4138) // Wx: '*/' found outside of comment # pragma warning(disable: 4097) // W3: typedef-name 'A' used as synonym for class-name 'B' # pragma warning(disable: 4511) // W3: 'class': copy constructor could not be generated # pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated diff --git a/src/p_elf.h b/src/p_elf.h index 5d7bb1f0..e0750105 100644 --- a/src/p_elf.h +++ b/src/p_elf.h @@ -193,7 +193,8 @@ __packed_struct(Sym) static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); } static unsigned int get_st_type(unsigned x) { return 0xf & x ; } - static unsigned char make_st_info(unsigned bind, unsigned type) { return (bind<<4) + (0xf & type); } + static unsigned char make_st_info(unsigned bind, unsigned type) + { return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); } __packed_struct_end() @@ -269,7 +270,8 @@ __packed_struct(Sym) static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); } static unsigned int get_st_type(unsigned x) { return 0xf & x ; } - static unsigned char make_st_info(unsigned bind, unsigned type) { return (bind<<4) + (0xf & type); } + static unsigned char make_st_info(unsigned bind, unsigned type) + { return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); } __packed_struct_end() diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 3a0f5bd3..e5bef2e6 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -1672,7 +1672,7 @@ PackLinuxElf64::generateElfHdr( } } -void PackLinuxElf32::pack1(OutputFile */*fo*/, Filter &/*ft*/) +void PackLinuxElf32::pack1(OutputFile * /*fo*/, Filter & /*ft*/) { fi->seek(0, SEEK_SET); fi->readx(&ehdri, sizeof(ehdri)); @@ -1774,7 +1774,7 @@ void PackLinuxElf32ppc::pack1(OutputFile *fo, Filter &ft) generateElfHdr(fo, stub_powerpc_linux_elf_fold, getbrk(phdri, e_phnum) ); } -void PackLinuxElf64::pack1(OutputFile */*fo*/, Filter &/*ft*/) +void PackLinuxElf64::pack1(OutputFile * /*fo*/, Filter & /*ft*/) { fi->seek(0, SEEK_SET); fi->readx(&ehdri, sizeof(ehdri)); @@ -2997,7 +2997,7 @@ void PackLinuxElf32::unpack(OutputFile *fo) #undef MAX_ELF_HDR } -void PackLinuxElf::unpack(OutputFile */*fo*/) +void PackLinuxElf::unpack(OutputFile * /*fo*/) { throwCantUnpack("internal error"); } diff --git a/src/p_mach.cpp b/src/p_mach.cpp index c7a65762..e3e5903f 100644 --- a/src/p_mach.cpp +++ b/src/p_mach.cpp @@ -275,7 +275,7 @@ void PackMachI386::addStubEntrySections(Filter const *ft) addLoader("FOLDEXEC", NULL); } -void PackMachAMD64::addStubEntrySections(Filter const */*ft*/) +void PackMachAMD64::addStubEntrySections(Filter const * /*ft*/) { addLoader("MACHMAINX", NULL); //addLoader(getDecompressorSections(), NULL); @@ -290,7 +290,7 @@ void PackMachAMD64::addStubEntrySections(Filter const */*ft*/) addLoader("MACHMAINY,IDENTSTR,+40,MACHMAINZ,FOLDEXEC", NULL); } -void PackMachARMEL::addStubEntrySections(Filter const */*ft*/) +void PackMachARMEL::addStubEntrySections(Filter const * /*ft*/) { addLoader("MACHMAINX", NULL); //addLoader(getDecompressorSections(), NULL); @@ -806,7 +806,7 @@ void PackDylibAMD64::pack3(OutputFile *fo, Filter &ft) // append loader disp64= len; fo->write(&disp64, sizeof(disp64)); // __mod_init_func - + disp = prev_init_address; fo->write(&disp, sizeof(disp)); // user .init_address @@ -872,7 +872,7 @@ unsigned PackMachBase::find_SEGMENT_gap( } if (lc_seg==msegcmd[j].cmd && 0!=msegcmd[j].filesize ) { - unsigned const t = msegcmd[j].fileoff; + unsigned const t = (unsigned) msegcmd[j].fileoff; if ((t - hi) < (lo - hi)) { lo = t; if (hi==lo) { @@ -935,7 +935,7 @@ void PackMachBase::pack2(OutputFile *fo, Filter &ft) // append compressed bo if (lc_seg==msegcmd[k].cmd && 0!=(Mach_segment_command::VM_PROT_EXECUTE & msegcmd[k].initprot) && exe_filesize_max < msegcmd[k].filesize) { - exe_filesize_max = msegcmd[k].filesize; + exe_filesize_max = (unsigned) msegcmd[k].filesize; } int nx = 0; @@ -1176,7 +1176,7 @@ bool PackMachBase::canPack() fi->seek(0, SEEK_SET); fi->readx(&mhdri, sizeof(mhdri)); - if ((Mach_header::MH_MAGIC + (sizeof(Addr)>>3)) !=mhdri.magic + if (((unsigned) Mach_header::MH_MAGIC + (sizeof(Addr)>>3)) !=mhdri.magic || my_cputype !=mhdri.cputype || my_filetype !=mhdri.filetype ) @@ -1421,11 +1421,10 @@ bool PackMachFat::canPack() fi->set_extent(fat_head.arch[j].offset, fat_head.arch[j].size); fi->seek(0, SEEK_SET); switch (arch[j].cputype) { - default: { + default: infoWarning("unknown cputype 0x%x: %s", (unsigned)arch[j].cputype, fi->getName()); return false; - } break; case PackMachFat::CPU_TYPE_I386: { PackMachI386 packer(fi); if (!packer.canPack()) { @@ -1505,7 +1504,7 @@ int PackMachFat::canUnpack() return 1; } -void PackMachFat::buildLoader(const Filter */*ft*/) +void PackMachFat::buildLoader(const Filter * /*ft*/) { assert(false); }