Merge "Fix more system/core/include warnings"
am: 18fbd80504
Change-Id: I9450a77271cdc42cc7db30461769ddb18f2e5af4
This commit is contained in:
commit
5fe194a9fd
7 changed files with 45 additions and 23 deletions
|
|
@ -26,7 +26,14 @@ typedef struct native_handle
|
||||||
int version; /* sizeof(native_handle_t) */
|
int version; /* sizeof(native_handle_t) */
|
||||||
int numFds; /* number of file-descriptors at &data[0] */
|
int numFds; /* number of file-descriptors at &data[0] */
|
||||||
int numInts; /* number of ints at &data[numFds] */
|
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 */
|
int data[0]; /* numFds + numInts ints */
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
} native_handle_t;
|
} native_handle_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -31,32 +31,32 @@ namespace android {
|
||||||
|
|
||||||
class FlattenableUtils {
|
class FlattenableUtils {
|
||||||
public:
|
public:
|
||||||
template<int N>
|
template<size_t N>
|
||||||
static size_t align(size_t size) {
|
static size_t align(size_t size) {
|
||||||
COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
|
COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
|
||||||
return (size + (N-1)) & ~(N-1);
|
return (size + (N-1)) & ~(N-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int N>
|
template<size_t N>
|
||||||
static size_t align(void const*& buffer) {
|
static size_t align(void const*& buffer) {
|
||||||
COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
|
COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
|
||||||
intptr_t b = intptr_t(buffer);
|
uintptr_t b = uintptr_t(buffer);
|
||||||
buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1));
|
buffer = reinterpret_cast<void*>((uintptr_t(buffer) + (N-1)) & ~(N-1));
|
||||||
return size_t(intptr_t(buffer) - b);
|
return size_t(uintptr_t(buffer) - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int N>
|
template<size_t N>
|
||||||
static size_t align(void*& buffer) {
|
static size_t align(void*& buffer) {
|
||||||
return align<N>( const_cast<void const*&>(buffer) );
|
return align<N>( const_cast<void const*&>(buffer) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void advance(void*& buffer, size_t& size, size_t offset) {
|
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;
|
size -= offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void advance(void const*& buffer, size_t& size, size_t 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;
|
size -= offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ template<typename KEY, typename VALUE> inline
|
||||||
VALUE& KeyedVector<KEY,VALUE>::editValueFor(const KEY& key) {
|
VALUE& KeyedVector<KEY,VALUE>::editValueFor(const KEY& key) {
|
||||||
ssize_t i = this->indexOfKey(key);
|
ssize_t i = this->indexOfKey(key);
|
||||||
LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__);
|
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
|
template<typename KEY, typename VALUE> inline
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
class ReferenceRenamer {
|
||||||
protected:
|
protected:
|
||||||
// destructor is purposedly not virtual so we avoid code overhead from
|
// destructor is purposedly not virtual so we avoid code overhead from
|
||||||
// subclasses; we have to make it protected to guarantee that it
|
// subclasses; we have to make it protected to guarantee that it
|
||||||
// cannot be called from this base class (and to make strict compilers
|
// cannot be called from this base class (and to make strict compilers
|
||||||
// happy).
|
// happy).
|
||||||
~ReferenceRenamer();
|
~ReferenceRenamer() { }
|
||||||
public:
|
public:
|
||||||
virtual void operator()(size_t i) const = 0;
|
virtual void operator()(size_t i) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class RefBase
|
class RefBase
|
||||||
|
|
|
||||||
|
|
@ -151,16 +151,21 @@ void destroy_type(TYPE* p, size_t n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TYPE> inline
|
template<typename TYPE>
|
||||||
void copy_type(TYPE* d, const TYPE* s, size_t n) {
|
typename std::enable_if<traits<TYPE>::has_trivial_copy>::type
|
||||||
if (!traits<TYPE>::has_trivial_copy) {
|
inline
|
||||||
while (n > 0) {
|
copy_type(TYPE* d, const TYPE* s, size_t n) {
|
||||||
n--;
|
memcpy(d,s,n*sizeof(TYPE));
|
||||||
new(d) TYPE(*s);
|
}
|
||||||
d++, s++;
|
|
||||||
}
|
template<typename TYPE>
|
||||||
} else {
|
typename std::enable_if<!traits<TYPE>::has_trivial_copy>::type
|
||||||
memcpy(d,s,n*sizeof(TYPE));
|
inline
|
||||||
|
copy_type(TYPE* d, const TYPE* s, size_t n) {
|
||||||
|
while (n > 0) {
|
||||||
|
n--;
|
||||||
|
new(d) TYPE(*s);
|
||||||
|
d++, s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ public:
|
||||||
inline void push_back(const TYPE& item) { insertAt(item, size(), 1); }
|
inline void push_back(const TYPE& item) { insertAt(item, size(), 1); }
|
||||||
inline void push_front(const TYPE& item) { insertAt(item, 0, 1); }
|
inline void push_front(const TYPE& item) { insertAt(item, 0, 1); }
|
||||||
inline iterator erase(iterator pos) {
|
inline iterator erase(iterator pos) {
|
||||||
ssize_t index = removeItemsAt(pos-array());
|
ssize_t index = removeItemsAt(static_cast<size_t>(pos-array()));
|
||||||
return begin() + index;
|
return begin() + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -770,8 +770,6 @@ void RefBase::renameRefId(RefBase* ref,
|
||||||
ref->mRefs->renameWeakRefId(old_id, new_id);
|
ref->mRefs->renameWeakRefId(old_id, new_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReferenceRenamer::~ReferenceRenamer() {}
|
|
||||||
|
|
||||||
VirtualLightRefBase::~VirtualLightRefBase() {}
|
VirtualLightRefBase::~VirtualLightRefBase() {}
|
||||||
|
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue