diff --git a/src/p_ps1.cpp b/src/p_ps1.cpp index 3bbb9b6a..aa7a148e 100644 --- a/src/p_ps1.cpp +++ b/src/p_ps1.cpp @@ -418,7 +418,7 @@ void PackPs1::buildLoader(const Filter *) bool PackPs1::findBssSection() { unsigned char reg; - LE32 *p1 = (LE32 *)(ibuf + (ih.epc - ih.tx_ptr)); + const LE32 * const p1 = ACC_CCAST(const LE32 *, ibuf + (ih.epc - ih.tx_ptr)); if ((ih.epc - ih.tx_ptr + (BSS_CHK_LIMIT * 4)) > fdata_size) return false; @@ -433,7 +433,7 @@ bool PackPs1::findBssSection() reg = REG1(op); for (; i >= 0; i--) { - bss_nfo *p = (bss_nfo *)(void *)&p1[i]; + const bss_nfo * const p = ACC_CCAST(const bss_nfo *, &p1[i]); upx_uint16_t op1 = p->op1, op2 = p->op2; // check for la (x),bss_start diff --git a/src/p_vmlinz.cpp b/src/p_vmlinz.cpp index fa63a820..7727abd4 100644 --- a/src/p_vmlinz.cpp +++ b/src/p_vmlinz.cpp @@ -969,12 +969,12 @@ unsigned PackVmlinuzARMEL::write_vmlinuz_head(OutputFile *const fo) fo->write(&stub_arm_v5a_linux_kernel_vmlinuz_head[0], 4); // Second word - LE32 tmp_u32; + upx_uint32_t tmp_u32; unsigned const t = (0xff000000 & get_te32(&stub_arm_v5a_linux_kernel_vmlinuz_head[4])) | (0x00ffffff & (0u - 1 + ((3+ ph.c_len)>>2))); - tmp_u32 = t; - fo->write((void const *)&tmp_u32, 4); + set_te32(&tmp_u32, t); + fo->write(&tmp_u32, 4); return sizeof(stub_arm_v5a_linux_kernel_vmlinuz_head); } diff --git a/src/work.cpp b/src/work.cpp index 6457b0c8..e60b4b20 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -65,13 +65,17 @@ void do_one_file(const char *iname, char *oname) struct stat st; memset(&st, 0, sizeof(st)); #if (HAVE_LSTAT) - r = lstat(iname,&st); + r = lstat(iname, &st); #else - r = stat(iname,&st); + r = stat(iname, &st); #endif - if (r != 0) - throw FileNotFoundException(iname); + { + if (errno == ENOENT) + throw FileNotFoundException(iname, errno); + else + throwIOException(iname, errno); + } if (!(S_ISREG(st.st_mode))) throwIOException("not a regular file -- skipped"); #if defined(__unix__)