src: add some "explicit"; cleanups
This commit is contained in:
@@ -48,7 +48,7 @@ protected:
|
||||
size_type size_in_bytes;
|
||||
|
||||
public:
|
||||
inline MemBufferBase() noexcept : ptr(nullptr), size_in_bytes(0) {}
|
||||
explicit inline MemBufferBase() noexcept : ptr(nullptr), size_in_bytes(0) {}
|
||||
forceinline ~MemBufferBase() noexcept {}
|
||||
|
||||
// IMPORTANT NOTE: automatic conversion to underlying pointer
|
||||
@@ -148,7 +148,7 @@ inline typename MemBufferBase<T>::pointer raw_index_bytes(const MemBufferBase<T>
|
||||
|
||||
class MemBuffer final : public MemBufferBase<byte> {
|
||||
public:
|
||||
inline MemBuffer() noexcept : MemBufferBase<byte>() {}
|
||||
explicit inline MemBuffer() noexcept : MemBufferBase<byte>() {}
|
||||
explicit MemBuffer(upx_uint64_t bytes);
|
||||
~MemBuffer() noexcept;
|
||||
|
||||
|
||||
+4
-4
@@ -151,7 +151,7 @@ void uintptr_check_no_overlap(upx_uintptr_t a, size_t a_size, upx_uintptr_t b, s
|
||||
if very_unlikely (a_end < a || b_end < b) // wrap-around
|
||||
throwCantPack("ptr_check_no_overlap-overflow");
|
||||
// same as (!(a >= b_end || b >= a_end))
|
||||
if (a < b_end && b < a_end)
|
||||
if very_unlikely (a < b_end && b < a_end)
|
||||
throwCantPack("ptr_check_no_overlap-ab");
|
||||
}
|
||||
|
||||
@@ -165,11 +165,11 @@ void uintptr_check_no_overlap(upx_uintptr_t a, size_t a_size, upx_uintptr_t b, s
|
||||
upx_uintptr_t c_end = c + mem_size(1, c_size);
|
||||
if very_unlikely (a_end < a || b_end < b || c_end < c) // wrap-around
|
||||
throwCantPack("ptr_check_no_overlap-overflow");
|
||||
if (a < b_end && b < a_end)
|
||||
if very_unlikely (a < b_end && b < a_end)
|
||||
throwCantPack("ptr_check_no_overlap-ab");
|
||||
if (a < c_end && c < a_end)
|
||||
if very_unlikely (a < c_end && c < a_end)
|
||||
throwCantPack("ptr_check_no_overlap-ac");
|
||||
if (b < c_end && c < b_end)
|
||||
if very_unlikely (b < c_end && c < b_end)
|
||||
throwCantPack("ptr_check_no_overlap-bc");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ using XSPAN_NAMESPACE_NAME::raw_index_bytes; // overloaded for all classes
|
||||
|
||||
// helper for implicit pointer conversions and MemBuffer overloads
|
||||
template <class R, class T>
|
||||
inline R *xspan_make_helper__(R * /*dummy*/, T *first) /*may_throw*/ {
|
||||
inline R *xspan_make_helper__(R * /*dummy*/, T *first) may_throw {
|
||||
return first; // IMPORTANT: no cast here to detect bad usage
|
||||
}
|
||||
template <class R>
|
||||
|
||||
@@ -394,31 +394,31 @@ public:
|
||||
|
||||
private:
|
||||
pointer check_deref(pointer p) const {
|
||||
assertInvariants();
|
||||
if __acc_cte (!configRequirePtr && p == nullptr)
|
||||
xspan_fail_nullptr();
|
||||
if __acc_cte (configRequireBase || base != nullptr)
|
||||
xspan_check_range(p, base, size_in_bytes - sizeof(T));
|
||||
assertInvariants();
|
||||
return p;
|
||||
}
|
||||
pointer check_deref(pointer p, ptrdiff_t n) const {
|
||||
assertInvariants();
|
||||
if __acc_cte (!configRequirePtr && p == nullptr)
|
||||
xspan_fail_nullptr();
|
||||
xspan_mem_size_assert_ptrdiff<T>(n);
|
||||
p += n;
|
||||
if __acc_cte (configRequireBase || base != nullptr)
|
||||
xspan_check_range(p, base, size_in_bytes - sizeof(T));
|
||||
assertInvariants();
|
||||
return p;
|
||||
}
|
||||
pointer check_add(pointer p, ptrdiff_t n) const {
|
||||
assertInvariants();
|
||||
if __acc_cte (!configRequirePtr && p == nullptr)
|
||||
xspan_fail_nullptr();
|
||||
xspan_mem_size_assert_ptrdiff<T>(n);
|
||||
p += n;
|
||||
if __acc_cte (configRequireBase || base != nullptr)
|
||||
xspan_check_range(p, base, size_in_bytes);
|
||||
assertInvariants();
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user