Make code -Wshadow warning free.

This commit is contained in:
Markus F.X.J. Oberhumer
2006-06-11 12:25:19 +02:00
parent d461b53235
commit c34daf1a35
4 changed files with 23 additions and 24 deletions
+1
View File
@@ -59,6 +59,7 @@ upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
ifeq ($(USE_GNUC),1) ifeq ($(USE_GNUC),1)
compress_lzma$(objext) : EXTRA_CXXFLAGS += -Wno-cast-qual compress_lzma$(objext) : EXTRA_CXXFLAGS += -Wno-cast-qual
compress_lzma$(objext) : EXTRA_CXXFLAGS += -Wno-non-virtual-dtor compress_lzma$(objext) : EXTRA_CXXFLAGS += -Wno-non-virtual-dtor
compress_lzma$(objext) : EXTRA_CXXFLAGS += -Wno-shadow
compress_lzma$(objext) : EXTRA_CXXFLAGS += -Wno-unused compress_lzma$(objext) : EXTRA_CXXFLAGS += -Wno-unused
##compress_lzma$(objext) : EXTRA_CXXFLAGS += -Wno-error ##compress_lzma$(objext) : EXTRA_CXXFLAGS += -Wno-error
endif endif
+4 -4
View File
@@ -1433,16 +1433,16 @@ static bool match(unsigned itype, const unsigned char *ntype,
struct helper struct helper
{ {
static bool match(unsigned num, const unsigned char *unistr, static bool match(unsigned num, const unsigned char *unistr,
const char *keep) const char *mkeep)
{ {
if (!unistr) if (!unistr)
return (unsigned) atoi(keep) == num; return (unsigned) atoi(mkeep) == num;
unsigned ic; unsigned ic;
for (ic = 0; ic < get_le16(unistr); ic++) for (ic = 0; ic < get_le16(unistr); ic++)
if (unistr[2 + ic * 2] != (unsigned char) keep[ic]) if (unistr[2 + ic * 2] != (unsigned char) mkeep[ic])
return false; return false;
return keep[ic] == 0 || keep[ic] == ',' || keep[ic] == '/'; return mkeep[ic] == 0 || mkeep[ic] == ',' || mkeep[ic] == '/';
}; };
}; };
+14 -16
View File
@@ -790,7 +790,6 @@ PackLinuxElf32::generateElfHdr(
#undef PAGE_MASK #undef PAGE_MASK
} }
if (ph.format==getFormat()) { if (ph.format==getFormat()) {
cprElfHdr2 *const h2 = (cprElfHdr2 *)&elfout;
assert(2==get_native16(&h2->ehdr.e_phnum)); assert(2==get_native16(&h2->ehdr.e_phnum));
set_native32(&h2->phdr[0].p_flags, ~Elf32_Phdr::PF_W & get_native32(&h2->phdr[0].p_flags)); set_native32(&h2->phdr[0].p_flags, ~Elf32_Phdr::PF_W & get_native32(&h2->phdr[0].p_flags));
memset(&h2->linfo, 0, sizeof(h2->linfo)); memset(&h2->linfo, 0, sizeof(h2->linfo));
@@ -842,7 +841,6 @@ PackLinuxElf64::generateElfHdr(
#undef PAGE_MASK #undef PAGE_MASK
} }
if (ph.format==getFormat()) { if (ph.format==getFormat()) {
cprElfHdr2 *const h2 = (cprElfHdr2 *)&elfout;
assert(2==get_native16(&h2->ehdr.e_phnum)); assert(2==get_native16(&h2->ehdr.e_phnum));
set_native32(&h2->phdr[0].p_flags, ~Elf64_Phdr::PF_W & get_native32(&h2->phdr[0].p_flags)); set_native32(&h2->phdr[0].p_flags, ~Elf64_Phdr::PF_W & get_native32(&h2->phdr[0].p_flags));
memset(&h2->linfo, 0, sizeof(h2->linfo)); memset(&h2->linfo, 0, sizeof(h2->linfo));
@@ -909,21 +907,21 @@ void PackLinuxElf64amd::pack1(OutputFile *fo, Filter &ft)
generateElfHdr(fo, linux_elf64amd_fold, getbrk(phdri, ehdri.e_phnum) ); generateElfHdr(fo, linux_elf64amd_fold, getbrk(phdri, ehdri.e_phnum) );
} }
// Determine length of gap between PT_LOAD phdri[k] and closest PT_LOAD // Determine length of gap between PT_LOAD phdr[k] and closest PT_LOAD
// which follows in the file (or end-of-file). Optimize for common case // which follows in the file (or end-of-file). Optimize for common case
// where the PT_LOAD are adjacent ascending by .p_offset. Assume no overlap. // where the PT_LOAD are adjacent ascending by .p_offset. Assume no overlap.
unsigned PackLinuxElf32::find_LOAD_gap( unsigned PackLinuxElf32::find_LOAD_gap(
Elf32_Phdr const *const phdri, Elf32_Phdr const *const phdr,
unsigned const k, unsigned const k,
unsigned const e_phnum unsigned const e_phnum
) )
{ {
if (PT_LOAD32!=get_native32(&phdri[k].p_type)) { if (PT_LOAD32!=get_native32(&phdr[k].p_type)) {
return 0; return 0;
} }
unsigned const hi = get_native32(&phdri[k].p_offset) + unsigned const hi = get_native32(&phdr[k].p_offset) +
get_native32(&phdri[k].p_filesz); get_native32(&phdr[k].p_filesz);
unsigned lo = ph.u_file_size; unsigned lo = ph.u_file_size;
unsigned j = k; unsigned j = k;
for (;;) { // circular search, optimize for adjacent ascending for (;;) { // circular search, optimize for adjacent ascending
@@ -934,8 +932,8 @@ unsigned PackLinuxElf32::find_LOAD_gap(
if (k==j) { if (k==j) {
break; break;
} }
if (PT_LOAD32==get_native32(&phdri[j].p_type)) { if (PT_LOAD32==get_native32(&phdr[j].p_type)) {
unsigned const t = get_native32(&phdri[j].p_offset); unsigned const t = get_native32(&phdr[j].p_offset);
if ((t - hi) < (lo - hi)) { if ((t - hi) < (lo - hi)) {
lo = t; lo = t;
if (hi==lo) { if (hi==lo) {
@@ -1011,21 +1009,21 @@ void PackLinuxElf32::pack2(OutputFile *fo, Filter &ft)
set_native32(&elfout.phdr[0].p_filesz, fo->getBytesWritten()); set_native32(&elfout.phdr[0].p_filesz, fo->getBytesWritten());
} }
// Determine length of gap between PT_LOAD phdri[k] and closest PT_LOAD // Determine length of gap between PT_LOAD phdr[k] and closest PT_LOAD
// which follows in the file (or end-of-file). Optimize for common case // which follows in the file (or end-of-file). Optimize for common case
// where the PT_LOAD are adjacent ascending by .p_offset. Assume no overlap. // where the PT_LOAD are adjacent ascending by .p_offset. Assume no overlap.
unsigned PackLinuxElf64::find_LOAD_gap( unsigned PackLinuxElf64::find_LOAD_gap(
Elf64_Phdr const *const phdri, Elf64_Phdr const *const phdr,
unsigned const k, unsigned const k,
unsigned const e_phnum unsigned const e_phnum
) )
{ {
if (PT_LOAD64!=get_native32(&phdri[k].p_type)) { if (PT_LOAD64!=get_native32(&phdr[k].p_type)) {
return 0; return 0;
} }
unsigned const hi = get_native64(&phdri[k].p_offset) + unsigned const hi = get_native64(&phdr[k].p_offset) +
get_native64(&phdri[k].p_filesz); get_native64(&phdr[k].p_filesz);
unsigned lo = ph.u_file_size; unsigned lo = ph.u_file_size;
unsigned j = k; unsigned j = k;
for (;;) { // circular search, optimize for adjacent ascending for (;;) { // circular search, optimize for adjacent ascending
@@ -1036,8 +1034,8 @@ unsigned PackLinuxElf64::find_LOAD_gap(
if (k==j) { if (k==j) {
break; break;
} }
if (PT_LOAD64==get_native32(&phdri[j].p_type)) { if (PT_LOAD64==get_native32(&phdr[j].p_type)) {
unsigned const t = get_native64(&phdri[j].p_offset); unsigned const t = get_native64(&phdr[j].p_offset);
if ((t - hi) < (lo - hi)) { if ((t - hi) < (lo - hi)) {
lo = t; lo = t;
if (hi==lo) { if (hi==lo) {
+4 -4
View File
@@ -1391,16 +1391,16 @@ static bool match(unsigned itype, const unsigned char *ntype,
struct helper struct helper
{ {
static bool match(unsigned num, const unsigned char *unistr, static bool match(unsigned num, const unsigned char *unistr,
const char *keep) const char *mkeep)
{ {
if (!unistr) if (!unistr)
return (unsigned) atoi(keep) == num; return (unsigned) atoi(mkeep) == num;
unsigned ic; unsigned ic;
for (ic = 0; ic < get_le16(unistr); ic++) for (ic = 0; ic < get_le16(unistr); ic++)
if (unistr[2 + ic * 2] != (unsigned char) keep[ic]) if (unistr[2 + ic * 2] != (unsigned char) mkeep[ic])
return false; return false;
return keep[ic] == 0 || keep[ic] == ',' || keep[ic] == '/'; return mkeep[ic] == 0 || mkeep[ic] == ',' || mkeep[ic] == '/';
}; };
}; };