Silence some compilation warnings.

This commit is contained in:
Markus F.X.J. Oberhumer 2013-02-18 11:01:30 +01:00
parent 9c9fb6a485
commit 36dd35f238
6 changed files with 26 additions and 22 deletions

View File

@ -352,6 +352,7 @@ namespace MyLzma {
struct InStream: public ISequentialInStream, public CMyUnknownImp
{
virtual ~InStream() { }
MY_UNKNOWN_IMP
const Byte *b_buf; size_t b_size; size_t b_pos;
void Init(const Byte *data, size_t size) {
@ -372,6 +373,7 @@ STDMETHODIMP InStream::Read(void *data, UInt32 size, UInt32 *processedSize)
struct OutStream : public ISequentialOutStream, public CMyUnknownImp
{
virtual ~OutStream() { }
MY_UNKNOWN_IMP
Byte *b_buf; size_t b_size; size_t b_pos; bool overflow;
void Init(Byte *data, size_t size) {
@ -397,6 +399,7 @@ STDMETHODIMP OutStream::Write(const void *data, UInt32 size, UInt32 *processedSi
struct ProgressInfo : public ICompressProgressInfo, public CMyUnknownImp
{
virtual ~ProgressInfo() { }
MY_UNKNOWN_IMP
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
upx_callback_p cb;

View File

@ -98,7 +98,7 @@ static int F(Filter *f)
}
else {
#if (W_CTO != 0)
assert((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != cto8); // this should not happen
assert((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != (unsigned) cto8); // this should not happen
#endif
lastnoncall = ic;
noncalls++;
@ -133,7 +133,7 @@ static int U(Filter *f)
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
unsigned const word = get_be32(b+ic);
if ((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) == f->cto) {
if ((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) == (unsigned) f->cto) {
unsigned const jc = word & (~(~0u<<(26 - W_CTO)) & (~0u<<2));
set_be32(b+ic, (0xfc000003&word)|(0x03fffffc&(jc-ic-addvalue)));
f->calls++;

View File

@ -1748,6 +1748,8 @@ extern "C" {
# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __acc_cta_t[1-!(e)];}
# elif (ACC_CC_DMC || ACC_CC_PACIFICC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
# elif (ACC_CC_GNUC >= 0x040700ul) && defined(__cplusplus)
# define ACC_COMPILE_TIME_ASSERT(e) {enum {__acc_cta_e=1/!!(e)} __attribute__((__unused__));}
# elif (ACC_CC_GNUC >= 0x040700ul)
# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __acc_cta_t[1-2*!(e)] __attribute__((__unused__));}
# elif (ACC_CC_MSC && (_MSC_VER < 900))

View File

@ -102,7 +102,7 @@ PackLinuxElf32::checkEhdr(Elf32_Ehdr const *ehdr) const
int const type = get_te16(&ehdr->e_type);
if (type != Elf32_Ehdr::ET_EXEC && type != Elf32_Ehdr::ET_DYN)
return 2;
if (get_te16(&ehdr->e_machine) != e_machine)
if (get_te16(&ehdr->e_machine) != (unsigned) e_machine)
return 3;
if (get_te32(&ehdr->e_version) != Elf32_Ehdr::EV_CURRENT)
return 4;
@ -135,7 +135,7 @@ int
PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
{
const unsigned char * const buf = ehdr->e_ident;
unsigned osabi0 = buf[Elf32_Ehdr::EI_OSABI];
unsigned char osabi0 = buf[Elf32_Ehdr::EI_OSABI];
if (0==osabi0) {
osabi0 = opt->o_unix.osabi0;
}
@ -153,7 +153,7 @@ PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
int const type = get_te16(&ehdr->e_type);
if (type != Elf64_Ehdr::ET_EXEC && type != Elf64_Ehdr::ET_DYN)
return 2;
if (get_te16(&ehdr->e_machine) != e_machine)
if (get_te16(&ehdr->e_machine) != (unsigned) e_machine)
return 3;
if (get_te32(&ehdr->e_version) != Elf64_Ehdr::EV_CURRENT)
return 4;
@ -1241,7 +1241,7 @@ bool PackLinuxElf32::canPack()
return false;
}
unsigned osabi0 = u.buf[Elf32_Ehdr::EI_OSABI];
unsigned char osabi0 = u.buf[Elf32_Ehdr::EI_OSABI];
// The first PT_LOAD32 must cover the beginning of the file (0==p_offset).
Elf32_Phdr const *phdr = (Elf32_Phdr const *)(u.buf + e_phoff);
note_size = 0;
@ -2041,7 +2041,7 @@ void PackLinuxElf32::pack1(OutputFile *fo, Filter & /*ft*/)
//set the shstrtab
sec_strndx = &shdr[ehdri.e_shstrndx];
char *strtab = new char[sec_strndx->sh_size];
char *strtab = new char[(unsigned) sec_strndx->sh_size];
fi->seek(0,SEEK_SET);
fi->seek(sec_strndx->sh_offset,SEEK_SET);
fi->readx(strtab,sec_strndx->sh_size);
@ -2050,7 +2050,7 @@ void PackLinuxElf32::pack1(OutputFile *fo, Filter & /*ft*/)
Elf32_Shdr const *buildid = elf_find_section_name(".note.gnu.build-id");
if (buildid) {
unsigned char *data = new unsigned char[buildid->sh_size];
unsigned char *data = new unsigned char[(unsigned) buildid->sh_size];
memset(data,0,buildid->sh_size);
fi->seek(0,SEEK_SET);
fi->seek(buildid->sh_offset,SEEK_SET);
@ -2059,7 +2059,7 @@ void PackLinuxElf32::pack1(OutputFile *fo, Filter & /*ft*/)
buildid_data = data;
o_elf_shnum = 3;
memset(&shdrout.shdr,0,sizeof(shdrout));
memset(&shdrout,0,sizeof(shdrout));
//setup the build-id
memcpy(&shdrout.shdr[1],buildid, sizeof(shdrout.shdr[1]));
@ -2113,7 +2113,7 @@ void PackLinuxElf32armLe::pack1(OutputFile *fo, Filter &ft)
}
// Fighting over .e_ident[EI_ABIVERSION]: Debian armhf is latest culprit.
// So copy from input to output; but see PackLinuxElf32::generateElfHdr
memcpy(&h3.ehdr.e_ident, &ehdri.e_ident, sizeof(ehdri.e_ident));
memcpy(&h3.ehdr.e_ident[0], &ehdri.e_ident[0], sizeof(ehdri.e_ident));
set_te32(&h3.ehdr.e_flags, e_flags);
generateElfHdr(fo, &h3, getbrk(phdri, e_phnum) );
}
@ -2236,7 +2236,7 @@ void PackLinuxElf64::pack1(OutputFile *fo, Filter & /*ft*/)
//set the shstrtab
sec_strndx = &shdri[ehdri.e_shstrndx];
char *strtab = new char[sec_strndx->sh_size];
char *strtab = new char[(unsigned) sec_strndx->sh_size];
fi->seek(0,SEEK_SET);
fi->seek(sec_strndx->sh_offset,SEEK_SET);
fi->readx(strtab,sec_strndx->sh_size);
@ -2245,7 +2245,7 @@ void PackLinuxElf64::pack1(OutputFile *fo, Filter & /*ft*/)
Elf64_Shdr const *buildid = elf_find_section_name(".note.gnu.build-id");
if (buildid) {
unsigned char *data = new unsigned char[buildid->sh_size];
unsigned char *data = new unsigned char[(unsigned) buildid->sh_size];
memset(data,0,buildid->sh_size);
fi->seek(0,SEEK_SET);
fi->seek(buildid->sh_offset,SEEK_SET);
@ -2254,7 +2254,7 @@ void PackLinuxElf64::pack1(OutputFile *fo, Filter & /*ft*/)
buildid_data = data;
o_elf_shnum = 3;
memset(&shdrout.shdr,0,sizeof(shdrout));
memset(&shdrout,0,sizeof(shdrout));
//setup the build-id
memcpy(&shdrout.shdr[1],buildid, sizeof(shdrout.shdr[1]));

View File

@ -466,12 +466,12 @@ PackMachBase<T>::compare_segment_command(void const *const aa, void const *const
#undef PAGE_MASK
#undef PAGE_SIZE
#define PAGE_MASK (~0u<<12)
#define PAGE_SIZE -PAGE_MASK
#define PAGE_SIZE (0u-PAGE_MASK)
#undef PAGE_MASK64
#undef PAGE_SIZE64
#define PAGE_MASK64 (~(acc_uint64l_t)0<<12)
#define PAGE_SIZE64 -PAGE_MASK64
#define PAGE_SIZE64 ((acc_uint64l_t)0-PAGE_MASK64)
// At 2013-02-03 part of the source for codesign was
// http://opensource.apple.com/source/cctools/cctools-836/libstuff/ofile.c

View File

@ -508,22 +508,21 @@ int PackUnix::canUnpack()
int bufsize = 2*4096 + 2*small +1;
if (bufsize > fi->st_size())
bufsize = fi->st_size();
upx_byte buf[bufsize];
MemBuffer buf(bufsize);
fi->seek(-bufsize, SEEK_END);
fi->readx(buf, bufsize);
buf[small] = 1; // Prevent running off the low-address end.
upx_byte *ptr = &buf[bufsize];
while (0 == *--ptr) ;
ptr -= small;
int i = bufsize;
while (i > small && 0 == buf[--i]) { }
i -= small;
// allow incompressible extents
if (!getPackHeader(ptr, bufsize - (ptr - buf), true))
if (i < 0 || !getPackHeader(buf + i, bufsize - i, true))
return false;
int l = ph.buf_offset + ph.getPackHeaderSize();
if (l < 0 || l + 4 > bufsize)
throwCantUnpack("file corrupted");
overlay_offset = get_te32(ptr+l);
overlay_offset = get_te32(buf + i + l);
if ((off_t)overlay_offset >= file_size)
throwCantUnpack("file corrupted");