Loading libutils/binder/Android.bp +6 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,12 @@ cc_defaults { "VectorImpl.cpp", ], cflags: [ "-Winvalid-offsetof", "-Wsequence-point", "-Wzero-as-null-pointer-constant", ], apex_available: [ "//apex_available:anyapex", "//apex_available:platform", Loading libutils/binder/SharedBuffer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ SharedBuffer* SharedBuffer::editResize(size_t newSize) const LOG_ALWAYS_FATAL_IF((newSize >= (SIZE_MAX - sizeof(SharedBuffer))), "Invalid buffer size %zu", newSize); buf = (SharedBuffer*)realloc(buf, sizeof(SharedBuffer) + newSize); buf = (SharedBuffer*)realloc(reinterpret_cast<void*>(buf), sizeof(SharedBuffer) + newSize); if (buf != nullptr) { buf->mSize = newSize; return buf; Loading libutils/binder/String16.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,19 @@ #include "SharedBuffer.h" #define LIBUTILS_PRAGMA(arg) _Pragma(#arg) #if defined(__clang__) #define LIBUTILS_PRAGMA_FOR_COMPILER(arg) LIBUTILS_PRAGMA(clang arg) #elif defined(__GNUC__) #define LIBUTILS_PRAGMA_FOR_COMPILER(arg) LIBUTILS_PRAGMA(GCC arg) #else #define LIBUTILS_PRAGMA_FOR_COMPILER(arg) #endif #define LIBUTILS_IGNORE(warning_flag) \ LIBUTILS_PRAGMA_FOR_COMPILER(diagnostic push) \ LIBUTILS_PRAGMA_FOR_COMPILER(diagnostic ignored warning_flag) #define LIBUTILS_IGNORE_END() LIBUTILS_PRAGMA_FOR_COMPILER(diagnostic pop) namespace android { static const StaticString16 emptyString(u""); Loading Loading @@ -347,7 +360,9 @@ void String16::release() bool String16::isStaticString() const { // See String16.h for notes on the memory layout of String16::StaticData and // SharedBuffer. LIBUTILS_IGNORE("-Winvalid-offsetof") static_assert(sizeof(SharedBuffer) - offsetof(SharedBuffer, mClientMetadata) == 4); LIBUTILS_IGNORE_END() const uint32_t* p = reinterpret_cast<const uint32_t*>(mString); return (*(p - 1) & kIsSharedBufferAllocated) == 0; } Loading @@ -355,7 +370,9 @@ bool String16::isStaticString() const { size_t String16::staticStringSize() const { // See String16.h for notes on the memory layout of String16::StaticData and // SharedBuffer. LIBUTILS_IGNORE("-Winvalid-offsetof") static_assert(sizeof(SharedBuffer) - offsetof(SharedBuffer, mClientMetadata) == 4); LIBUTILS_IGNORE_END() const uint32_t* p = reinterpret_cast<const uint32_t*>(mString); return static_cast<size_t>(*(p - 1)); } Loading libutils/binder/include/utils/RefBase.h +4 −5 Original line number Diff line number Diff line Loading @@ -555,7 +555,7 @@ template<typename T> wp<T>::wp(T* other) : m_ptr(other) { m_refs = other ? m_refs = other->createWeak(this) : nullptr; m_refs = other ? other->createWeak(this) : nullptr; } template <typename T> Loading Loading @@ -662,8 +662,7 @@ wp<T>& wp<T>::operator = (const wp<U>& other) template<typename T> template<typename U> wp<T>& wp<T>::operator = (const sp<U>& other) { weakref_type* newRefs = other != nullptr ? other->createWeak(this) : 0; weakref_type* newRefs = other != nullptr ? other->createWeak(this) : nullptr; U* otherPtr(other.m_ptr); if (m_ptr) m_refs->decWeak(this); m_ptr = otherPtr; Loading Loading @@ -695,8 +694,8 @@ void wp<T>::clear() { if (m_ptr) { m_refs->decWeak(this); m_refs = 0; m_ptr = 0; m_refs = nullptr; m_ptr = nullptr; } } Loading libutils/binder/include/utils/TypeHelpers.h +2 −2 Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ template<typename TYPE> typename std::enable_if<use_trivial_move<TYPE>::value>::type inline move_forward_type(TYPE* d, const TYPE* s, size_t n = 1) { memmove(d, s, n*sizeof(TYPE)); memmove(reinterpret_cast<void*>(d), s, n * sizeof(TYPE)); } template<typename TYPE> Loading @@ -227,7 +227,7 @@ template<typename TYPE> typename std::enable_if<use_trivial_move<TYPE>::value>::type inline move_backward_type(TYPE* d, const TYPE* s, size_t n = 1) { memmove(d, s, n*sizeof(TYPE)); memmove(reinterpret_cast<void*>(d), s, n * sizeof(TYPE)); } template<typename TYPE> Loading Loading
libutils/binder/Android.bp +6 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,12 @@ cc_defaults { "VectorImpl.cpp", ], cflags: [ "-Winvalid-offsetof", "-Wsequence-point", "-Wzero-as-null-pointer-constant", ], apex_available: [ "//apex_available:anyapex", "//apex_available:platform", Loading
libutils/binder/SharedBuffer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ SharedBuffer* SharedBuffer::editResize(size_t newSize) const LOG_ALWAYS_FATAL_IF((newSize >= (SIZE_MAX - sizeof(SharedBuffer))), "Invalid buffer size %zu", newSize); buf = (SharedBuffer*)realloc(buf, sizeof(SharedBuffer) + newSize); buf = (SharedBuffer*)realloc(reinterpret_cast<void*>(buf), sizeof(SharedBuffer) + newSize); if (buf != nullptr) { buf->mSize = newSize; return buf; Loading
libutils/binder/String16.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,19 @@ #include "SharedBuffer.h" #define LIBUTILS_PRAGMA(arg) _Pragma(#arg) #if defined(__clang__) #define LIBUTILS_PRAGMA_FOR_COMPILER(arg) LIBUTILS_PRAGMA(clang arg) #elif defined(__GNUC__) #define LIBUTILS_PRAGMA_FOR_COMPILER(arg) LIBUTILS_PRAGMA(GCC arg) #else #define LIBUTILS_PRAGMA_FOR_COMPILER(arg) #endif #define LIBUTILS_IGNORE(warning_flag) \ LIBUTILS_PRAGMA_FOR_COMPILER(diagnostic push) \ LIBUTILS_PRAGMA_FOR_COMPILER(diagnostic ignored warning_flag) #define LIBUTILS_IGNORE_END() LIBUTILS_PRAGMA_FOR_COMPILER(diagnostic pop) namespace android { static const StaticString16 emptyString(u""); Loading Loading @@ -347,7 +360,9 @@ void String16::release() bool String16::isStaticString() const { // See String16.h for notes on the memory layout of String16::StaticData and // SharedBuffer. LIBUTILS_IGNORE("-Winvalid-offsetof") static_assert(sizeof(SharedBuffer) - offsetof(SharedBuffer, mClientMetadata) == 4); LIBUTILS_IGNORE_END() const uint32_t* p = reinterpret_cast<const uint32_t*>(mString); return (*(p - 1) & kIsSharedBufferAllocated) == 0; } Loading @@ -355,7 +370,9 @@ bool String16::isStaticString() const { size_t String16::staticStringSize() const { // See String16.h for notes on the memory layout of String16::StaticData and // SharedBuffer. LIBUTILS_IGNORE("-Winvalid-offsetof") static_assert(sizeof(SharedBuffer) - offsetof(SharedBuffer, mClientMetadata) == 4); LIBUTILS_IGNORE_END() const uint32_t* p = reinterpret_cast<const uint32_t*>(mString); return static_cast<size_t>(*(p - 1)); } Loading
libutils/binder/include/utils/RefBase.h +4 −5 Original line number Diff line number Diff line Loading @@ -555,7 +555,7 @@ template<typename T> wp<T>::wp(T* other) : m_ptr(other) { m_refs = other ? m_refs = other->createWeak(this) : nullptr; m_refs = other ? other->createWeak(this) : nullptr; } template <typename T> Loading Loading @@ -662,8 +662,7 @@ wp<T>& wp<T>::operator = (const wp<U>& other) template<typename T> template<typename U> wp<T>& wp<T>::operator = (const sp<U>& other) { weakref_type* newRefs = other != nullptr ? other->createWeak(this) : 0; weakref_type* newRefs = other != nullptr ? other->createWeak(this) : nullptr; U* otherPtr(other.m_ptr); if (m_ptr) m_refs->decWeak(this); m_ptr = otherPtr; Loading Loading @@ -695,8 +694,8 @@ void wp<T>::clear() { if (m_ptr) { m_refs->decWeak(this); m_refs = 0; m_ptr = 0; m_refs = nullptr; m_ptr = nullptr; } } Loading
libutils/binder/include/utils/TypeHelpers.h +2 −2 Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ template<typename TYPE> typename std::enable_if<use_trivial_move<TYPE>::value>::type inline move_forward_type(TYPE* d, const TYPE* s, size_t n = 1) { memmove(d, s, n*sizeof(TYPE)); memmove(reinterpret_cast<void*>(d), s, n * sizeof(TYPE)); } template<typename TYPE> Loading @@ -227,7 +227,7 @@ template<typename TYPE> typename std::enable_if<use_trivial_move<TYPE>::value>::type inline move_backward_type(TYPE* d, const TYPE* s, size_t n = 1) { memmove(d, s, n*sizeof(TYPE)); memmove(reinterpret_cast<void*>(d), s, n * sizeof(TYPE)); } template<typename TYPE> Loading