all: minor cleanups
This commit is contained in:
@@ -49,6 +49,8 @@ int upx_doctest_check(int argc, char **argv) {
|
||||
if (e && e[0]) {
|
||||
if (strcmp(e, "0") == 0) {
|
||||
minimal = true;
|
||||
} else if (strcmp(e, "1") == 0) {
|
||||
minimal = false;
|
||||
} else if (strcmp(e, "2") == 0) {
|
||||
minimal = false;
|
||||
duration = true;
|
||||
@@ -185,6 +187,12 @@ struct CheckIntegral {
|
||||
COMPILE_TIME_ASSERT(upx_is_integral_v<U>)
|
||||
}
|
||||
static void check(void) {
|
||||
T a = {};
|
||||
const T b = {};
|
||||
constexpr T c = {};
|
||||
assert(a == 0);
|
||||
assert(b == 0);
|
||||
assert(c == 0);
|
||||
checkU<T>();
|
||||
checkU<typename std::add_const<T>::type>();
|
||||
#if !defined(__GNUC__)
|
||||
|
||||
+2
-2
@@ -112,7 +112,7 @@ inline constexpr bool upx_is_integral_v = upx_is_integral<T>::value;
|
||||
// horrible hack for broken compiler
|
||||
#define upx_fake_alignas_1 __attribute__((__aligned__(1),__packed__))
|
||||
#define upx_fake_alignas_16 __attribute__((__aligned__(2))) // object file maximum 2 ???
|
||||
#define upx_fake_alignas__(a) upx_fake_alignas_ ## a
|
||||
#define upx_fake_alignas__(x) upx_fake_alignas_ ## x
|
||||
#define alignas(x) upx_fake_alignas__(x)
|
||||
#endif
|
||||
|
||||
@@ -555,7 +555,7 @@ constexpr bool string_ge(const char *a, const char *b) {
|
||||
#define M_IS_ZSTD(x) ((x) == M_ZSTD)
|
||||
|
||||
|
||||
// filters
|
||||
// filters internal usage
|
||||
#define FT_END (-1)
|
||||
#define FT_NONE (-2)
|
||||
#define FT_SKIP (-3)
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
// A MemBuffer allocates memory on the heap, and automatically
|
||||
// gets destructed when leaving scope or on exceptions.
|
||||
|
||||
#include "../conf.h"
|
||||
#include "membuffer.h"
|
||||
|
||||
@@ -256,7 +259,7 @@ void MemBuffer::dealloc() noexcept {
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("MemBuffer") {
|
||||
TEST_CASE("MemBuffer core") {
|
||||
MemBuffer mb;
|
||||
CHECK_THROWS(mb.checkState());
|
||||
CHECK_THROWS(mb.alloc(0x30000000 + 1));
|
||||
|
||||
@@ -119,17 +119,15 @@ inline typename MemBufferBase<T>::pointer raw_index_bytes(const MemBufferBase<T>
|
||||
return mbb.raw_bytes(mem_size(sizeof(element_type), index, size_in_bytes)) + index;
|
||||
}
|
||||
|
||||
#if 1
|
||||
// some more global overloads using a checked raw_bytes() call
|
||||
#define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType) \
|
||||
typename std::enable_if<std::is_same<A, B>::value, RType>::type
|
||||
#define XSPAN_FWD_C_IS_MEMBUFFER 1
|
||||
#define C MemBufferBase
|
||||
#define XSPAN_FWD_C_IS_MEMBUFFER 1
|
||||
#include "xspan_fwd.h"
|
||||
#undef C
|
||||
#undef XSPAN_FWD_C_IS_MEMBUFFER
|
||||
#undef C
|
||||
#undef XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
|
||||
+2
-2
@@ -76,10 +76,10 @@ void xspan_check_range(const void *p, const void *base, ptrdiff_t size_in_bytes)
|
||||
if very_unlikely (base == nullptr)
|
||||
xspan_fail_range_nullbase();
|
||||
ptrdiff_t off = (const charptr) p - (const charptr) base;
|
||||
if very_unlikely (off < 0 || off > size_in_bytes)
|
||||
if very_unlikely (off < 0 || off > size_in_bytes || size_in_bytes > UPX_RSIZE_MAX)
|
||||
xspan_fail_range_range();
|
||||
xspan_stats.check_range_counter += 1;
|
||||
// fprintf(stderr, "xspan_check_range done\n");
|
||||
NO_fprintf(stderr, "xspan_check_range done\n");
|
||||
}
|
||||
|
||||
XSPAN_NAMESPACE_END
|
||||
|
||||
Reference in New Issue
Block a user