1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

Add check_whitespace_git.sh. Minor cleanups.

This commit is contained in:
Markus F.X.J. Oberhumer 2016-10-03 01:32:03 +02:00
parent 870cdfa51f
commit 06eb244800
6 changed files with 50 additions and 9 deletions

View File

@ -72,6 +72,7 @@ ifeq ($(findstring clang,$(CXX)),)
CXXFLAGS += -fno-delete-null-pointer-checks
endif
CXXFLAGS += -fno-strict-aliasing -fwrapv
CXXFLAGS += -funsigned-char
CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wshadow -Wwrite-strings
CXXFLAGS_WERROR ?= -Werror
CXXFLAGS += $(CXXFLAGS_WERROR)
@ -85,16 +86,19 @@ compress_lzma$(objext) filteri$(objext) : CXXFLAGS := $(filter-out $(CXXFLAGS_SA
endif
all: check-whitespace upx$(exeext) | ./.depend
all: upx$(exeext) | ./.depend
.DELETE_ON_ERROR: upx$(exeext) $(upx_OBJECTS) ./.depend
upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
$($(notdir $@).PRE_LINK_STEP)
$(strip $(CXXLD) $(call e,CPPFLAGS) $(call e,CXXFLAGS) $(call e,LDFLAGS) -o $@ $(upx_OBJECTS) $(call e,LDADD) $(call e,LIBS))
$($(notdir $@).POST_LINK_STEP)
$(CHECK_WHITESPACE)
%.o : %.cpp | ./.depend
$(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -c $<)
%.cpp.ii : %.cpp | ./.depend
$(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -E $<)
ifeq ($(BUILD_USE_DEPEND),1)
./.depend: $(sort $(wildcard $(srcdir)/*.cpp $(srcdir)/*.h)) $(MAKEFILE_LIST)
@ -106,8 +110,13 @@ else
.PHONY: ./.depend
endif
CHECK_WHITESPACE =
ifeq ($(shell uname),Linux)
check-whitespace : ; bash $(top_srcdir)/src/stub/scripts/check_whitespace.sh $(top_srcdir)
CHECK_WHITESPACE = $(top_srcdir)/src/stub/scripts/check_whitespace.sh $(top_srcdir)
ifneq ($(wildcard $(top_srcdir)/.git/.),)
CHECK_WHITESPACE = $(top_srcdir)/src/stub/scripts/check_whitespace_git.sh $(top_srcdir)
endif
check-whitespace : ; $(CHECK_WHITESPACE)
endif
.PHONY: check-whitespace

View File

@ -344,7 +344,7 @@ void PackDjgpp2::pack(OutputFile *fo)
// because of a feature (bug?) in stub.asm we need some padding
memcpy(obuf+data->size, "UPX", 3);
data->size = ALIGN_UP(data->size, 4);
data->size = ALIGN_UP(data->size, 4u);
linker->defineSymbol("DJ2MAIN1", coff_hdr.a_entry);
relocateLoader();

View File

@ -547,7 +547,7 @@ void PackPs1::pack(OutputFile *fo)
const int lsize = getLoaderSize();
unsigned filelen = ALIGN_UP(ih.tx_len, 4);
unsigned filelen = ALIGN_UP(ih.tx_len, 4u);
const unsigned decomp_data_start = ih.tx_ptr;
const unsigned comp_data_start = (decomp_data_start + filelen + overlap) - ph.c_len;
@ -594,7 +594,7 @@ void PackPs1::pack(OutputFile *fo)
if (!opt->ps1_exe.no_align || !isCon)
{
pad = oh.tx_len;
oh.tx_len = ALIGN_UP(oh.tx_len, CD_SEC);
oh.tx_len = ALIGN_UP(oh.tx_len, CD_SEC+0u);
pad = oh.tx_len - pad;
oh.tx_ptr -= pad;
}

View File

@ -330,7 +330,7 @@ void PeFile::Reloc::finish(upx_byte *&p,unsigned &siz)
{
prev = pos;
*rel1 = 0;
rel->size = ALIGN_UP(ptr_diff(rel1,rel),4);
rel->size = ALIGN_UP(ptr_diff(rel1,rel), 4);
newRelocPos((char *)rel + rel->size);
rel->pagestart = (pos >> 4) &~ 0xfff;
}
@ -1177,7 +1177,7 @@ void PeFile::Export::build(char *newbase, unsigned newoffs)
void PeFile::processExports(Export *xport) // pass1
{
soexport = ALIGN_UP(IDSIZE(PEDIR_EXPORT),4);
soexport = ALIGN_UP(IDSIZE(PEDIR_EXPORT),4u);
if (soexport == 0)
return;
if (!isdll && opt->win32_pe.compress_exports)
@ -1258,7 +1258,7 @@ void PeFile::processTls1(Interval *iv,
COMPILE_TIME_ASSERT(sizeof(tls) == tls_traits<LEXX>::sotls)
COMPILE_TIME_ASSERT_ALIGNED1(tls)
if ((sotls = ALIGN_UP(IDSIZE(PEDIR_TLS),4)) == 0)
if ((sotls = ALIGN_UP(IDSIZE(PEDIR_TLS),4u)) == 0)
return;
const tls * const tlsp = (const tls*) (ibuf + IDADDR(PEDIR_TLS));
@ -1508,7 +1508,7 @@ const upx_byte *PeFile::Resource::ntype() const
unsigned PeFile::Resource::size() const
{
return ALIGN_UP(current->data.size,4);
return ALIGN_UP(current->data.size, 4u);
}
unsigned PeFile::Resource::offs() const

View File

@ -14,8 +14,10 @@ find . \
-type f -iname '*.bat' -prune -o \
-type f -iname '*.exe' -prune -o \
-type f -iname '*.pdf' -prune -o \
-type f -iname '*.swp' -prune -o \
-type f -print0 | LC_ALL=C sort -z | \
xargs -0r perl -n -e '
#print("$ARGV\n");
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
if (m,([ \t]+)$,) {
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files

View File

@ -0,0 +1,30 @@
#! /usr/bin/env bash
## vim:set ts=4 sw=4 et:
set -e; set -o pipefail
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
[[ -z $1 ]] || cd "$1" || exit 1
[[ -d .git ]] || exit 1
# info: cannot use "-z" as that needs GNU sed 4.2.2 which is not installed on Ubuntu 12.04
git ls-files --full-name | sed 's/^/\.\//' |\
sed -e '/lzma-sdk$/d' -e '/\.exe$/d' |\
LC_ALL=C sort | \
xargs -r perl -n -e '
#print("$ARGV\n");
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
if (m,([ \t]+)$,) {
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
if ($1 ne " " || $ARGV !~ m,\.md$,) {
print "ERROR: trailing whitespace detected $ARGV: $_"; exit(1);
}
}
if (m,\t,) {
if ($ARGV =~ m,(^|/)\.gitmodules$,) { }
elsif ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { }
elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { }
elsif ($ARGV =~ m,/src/stub/src/arch/.*\.S$,) { }
else { print "ERROR: hard TAB detected $ARGV: $_"; exit(1); }
}
' || exit 1