Merge "Fix more system/core/include warnings"

am: 18fbd80504

Change-Id: I9450a77271cdc42cc7db30461769ddb18f2e5af4
This commit is contained in:
Colin Cross 2016-09-29 17:32:30 +00:00 committed by android-build-merger
commit 5fe194a9fd
7 changed files with 45 additions and 23 deletions

View File

@ -26,7 +26,14 @@ typedef struct native_handle
int version; /* sizeof(native_handle_t) */
int numFds; /* number of file-descriptors at &data[0] */
int numInts; /* number of ints at &data[numFds] */
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wzero-length-array"
#endif
int data[0]; /* numFds + numInts ints */
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
} native_handle_t;
/*

View File

@ -31,32 +31,32 @@ namespace android {
class FlattenableUtils {
public:
template<int N>
template<size_t N>
static size_t align(size_t size) {
COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
return (size + (N-1)) & ~(N-1);
}
template<int N>
template<size_t N>
static size_t align(void const*& buffer) {
COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
intptr_t b = intptr_t(buffer);
buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1));
return size_t(intptr_t(buffer) - b);
uintptr_t b = uintptr_t(buffer);
buffer = reinterpret_cast<void*>((uintptr_t(buffer) + (N-1)) & ~(N-1));
return size_t(uintptr_t(buffer) - b);
}
template<int N>
template<size_t N>
static size_t align(void*& buffer) {
return align<N>( const_cast<void const*&>(buffer) );
}
static void advance(void*& buffer, size_t& size, size_t offset) {
buffer = reinterpret_cast<void*>( intptr_t(buffer) + offset );
buffer = reinterpret_cast<void*>( uintptr_t(buffer) + offset );
size -= offset;
}
static void advance(void const*& buffer, size_t& size, size_t offset) {
buffer = reinterpret_cast<void const*>( intptr_t(buffer) + offset );
buffer = reinterpret_cast<void const*>( uintptr_t(buffer) + offset );
size -= offset;
}

View File

@ -157,7 +157,7 @@ template<typename KEY, typename VALUE> inline
VALUE& KeyedVector<KEY,VALUE>::editValueFor(const KEY& key) {
ssize_t i = this->indexOfKey(key);
LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__);
return mVector.editItemAt(i).value;
return mVector.editItemAt(static_cast<size_t>(i)).value;
}
template<typename KEY, typename VALUE> inline

View File

@ -206,17 +206,29 @@ inline bool operator _op_ (const U* o) const { \
// ---------------------------------------------------------------------------
// RefererenceRenamer is pure abstract, there is no virtual method
// implementation to put in a translation unit in order to silence the
// weak vtables warning.
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wweak-vtables"
#endif
class ReferenceRenamer {
protected:
// destructor is purposedly not virtual so we avoid code overhead from
// subclasses; we have to make it protected to guarantee that it
// cannot be called from this base class (and to make strict compilers
// happy).
~ReferenceRenamer();
~ReferenceRenamer() { }
public:
virtual void operator()(size_t i) const = 0;
};
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
// ---------------------------------------------------------------------------
class RefBase

View File

@ -151,16 +151,21 @@ void destroy_type(TYPE* p, size_t n) {
}
}
template<typename TYPE> inline
void copy_type(TYPE* d, const TYPE* s, size_t n) {
if (!traits<TYPE>::has_trivial_copy) {
while (n > 0) {
n--;
new(d) TYPE(*s);
d++, s++;
}
} else {
memcpy(d,s,n*sizeof(TYPE));
template<typename TYPE>
typename std::enable_if<traits<TYPE>::has_trivial_copy>::type
inline
copy_type(TYPE* d, const TYPE* s, size_t n) {
memcpy(d,s,n*sizeof(TYPE));
}
template<typename TYPE>
typename std::enable_if<!traits<TYPE>::has_trivial_copy>::type
inline
copy_type(TYPE* d, const TYPE* s, size_t n) {
while (n > 0) {
n--;
new(d) TYPE(*s);
d++, s++;
}
}

View File

@ -194,7 +194,7 @@ public:
inline void push_back(const TYPE& item) { insertAt(item, size(), 1); }
inline void push_front(const TYPE& item) { insertAt(item, 0, 1); }
inline iterator erase(iterator pos) {
ssize_t index = removeItemsAt(pos-array());
ssize_t index = removeItemsAt(static_cast<size_t>(pos-array()));
return begin() + index;
}

View File

@ -770,8 +770,6 @@ void RefBase::renameRefId(RefBase* ref,
ref->mRefs->renameWeakRefId(old_id, new_id);
}
ReferenceRenamer::~ReferenceRenamer() {}
VirtualLightRefBase::~VirtualLightRefBase() {}
}; // namespace android