Use new style casts. Cleanups.

This commit is contained in:
Markus F.X.J. Oberhumer 2016-09-20 20:59:34 +02:00
parent 2076bef95b
commit 7af6c4b10e
5 changed files with 13 additions and 11 deletions

View File

@ -99,7 +99,7 @@ int upx_zlib_compress ( const upx_bytep src, unsigned src_len,
z_stream s;
s.zalloc = (alloc_func) 0;
s.zfree = (free_func) 0;
s.next_in = const_cast<upx_bytep>(src); // UNCONST
s.next_in = ACC_UNCONST_CAST(upx_bytep, src);
s.avail_in = src_len;
s.next_out = dst;
s.avail_out = *dst_len;
@ -153,7 +153,7 @@ int upx_zlib_decompress ( const upx_bytep src, unsigned src_len,
z_stream s;
s.zalloc = (alloc_func) 0;
s.zfree = (free_func) 0;
s.next_in = const_cast<upx_bytep>(src); // UNCONST
s.next_in = ACC_UNCONST_CAST(upx_bytep, src);
s.avail_in = src_len;
s.next_out = dst;
s.avail_out = *dst_len;

View File

@ -36,6 +36,9 @@
// ACC
**************************************************************************/
#ifndef ACC_CFG_USE_NEW_STYLE_CASTS
#define ACC_CFG_USE_NEW_STYLE_CASTS 1
#endif
#include "miniacc.h"
#if !(ACC_CC_CLANG || ACC_CC_GNUC)
# error "only clang and gcc are officially supported"
@ -108,8 +111,8 @@ typedef acc_uintptr_t upx_uintptr_t;
#if !defined(WITH_LZMA) || (WITH_LZMA+0 == 0)
# error "WITH_LZMA is missing"
#endif
#if (WITH_LZMA+0 != 0x443)
# error "invalud WITH_LZMA"
#if (WITH_LZMA != 0x443)
# error "invalid WITH_LZMA version"
#endif
#if defined(UPX_OFFICIAL_BUILD)
# if !(WITH_LZMA) || !(WITH_NRV) || !(WITH_UCL)

View File

@ -2125,12 +2125,12 @@ PackNetBSDElf32x86::generateElfHdr(
set_te32(&phdr->p_flags, Elf32_Phdr::PF_R);
set_te32(&phdr->p_align, 4);
unsigned bits = get_te32( /* &np_PaX->body[4] */
&(ACC_UNCONST_CAST(unsigned char *, (1+ np_PaX)))[4] );
/* &np_PaX->body[4] */
const unsigned char *p4 = &(ACC_STATIC_CAST2(const unsigned char *, const void *, (1+ np_PaX)))[4];
unsigned bits = get_te32(p4);
bits &= ~PAX_MPROTECT;
bits |= PAX_NOMPROTECT;
set_te32( /* &np_PaX->body[4] */
&(ACC_UNCONST_CAST(unsigned char *, (1+ np_PaX)))[4], bits);
set_te32(ACC_UNCONST_CAST(unsigned char *, p4), bits);
sz_elf_hdrs += sz_PaX + sizeof(*phdr);
note_offset += sz_PaX;

View File

@ -26,7 +26,6 @@
*/
//#define WANT_STL 1
#include "conf.h"
#include "file.h"
#include "packer.h"

View File

@ -761,13 +761,13 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
**************************************************************************/
// UPX version with assertions
static int xdopr(char *buffer, size_t maxlen, const char *format, va_list args) {
__acc_static_noinline int xdopr(char *buffer, size_t maxlen, const char *format, va_list args) {
size_t ret;
// preconditions
assert(maxlen < INT_MAX);
if (buffer != NULL)
assert((int) maxlen > 0);
assert(maxlen > 0);
else
assert(maxlen == 0);