summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross2016-09-29 12:58:08 -0500
committerandroid-build-merger2016-09-29 12:58:08 -0500
commit0763c30289a320140f4330cf251a797e7cdd8bb8 (patch)
tree13cf44034645d72ba84bf1f5618c3ccbefcfd2ad /include/utils
parente96fcf044f9db03ba263897a31e44c7934850f03 (diff)
parentb5ca47989cd579b119446df57977391992844cba (diff)
downloadplatform-system-core-0763c30289a320140f4330cf251a797e7cdd8bb8.tar.gz
platform-system-core-0763c30289a320140f4330cf251a797e7cdd8bb8.tar.xz
platform-system-core-0763c30289a320140f4330cf251a797e7cdd8bb8.zip
Merge "Fix more system/core/include warnings" am: 18fbd80504 am: 5fe194a9fd
am: b5ca47989c Change-Id: I8d5a602f94bc57866aa3827cc508c94afb4ac4ba
Diffstat (limited to 'include/utils')
-rw-r--r--include/utils/Flattenable.h16
-rw-r--r--include/utils/KeyedVector.h2
-rw-r--r--include/utils/RefBase.h14
-rw-r--r--include/utils/TypeHelpers.h25
-rw-r--r--include/utils/Vector.h2
5 files changed, 38 insertions, 21 deletions
diff --git a/include/utils/Flattenable.h b/include/utils/Flattenable.h
index c37ac60c7..22b811a14 100644
--- a/include/utils/Flattenable.h
+++ b/include/utils/Flattenable.h
@@ -31,32 +31,32 @@ namespace android {
31 31
32class FlattenableUtils { 32class FlattenableUtils {
33public: 33public:
34 template<int N> 34 template<size_t N>
35 static size_t align(size_t size) { 35 static size_t align(size_t size) {
36 COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); 36 COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
37 return (size + (N-1)) & ~(N-1); 37 return (size + (N-1)) & ~(N-1);
38 } 38 }
39 39
40 template<int N> 40 template<size_t N>
41 static size_t align(void const*& buffer) { 41 static size_t align(void const*& buffer) {
42 COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); 42 COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
43 intptr_t b = intptr_t(buffer); 43 uintptr_t b = uintptr_t(buffer);
44 buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1)); 44 buffer = reinterpret_cast<void*>((uintptr_t(buffer) + (N-1)) & ~(N-1));
45 return size_t(intptr_t(buffer) - b); 45 return size_t(uintptr_t(buffer) - b);
46 } 46 }
47 47
48 template<int N> 48 template<size_t N>
49 static size_t align(void*& buffer) { 49 static size_t align(void*& buffer) {
50 return align<N>( const_cast<void const*&>(buffer) ); 50 return align<N>( const_cast<void const*&>(buffer) );
51 } 51 }
52 52
53 static void advance(void*& buffer, size_t& size, size_t offset) { 53 static void advance(void*& buffer, size_t& size, size_t offset) {
54 buffer = reinterpret_cast<void*>( intptr_t(buffer) + offset ); 54 buffer = reinterpret_cast<void*>( uintptr_t(buffer) + offset );
55 size -= offset; 55 size -= offset;
56 } 56 }
57 57
58 static void advance(void const*& buffer, size_t& size, size_t offset) { 58 static void advance(void const*& buffer, size_t& size, size_t offset) {
59 buffer = reinterpret_cast<void const*>( intptr_t(buffer) + offset ); 59 buffer = reinterpret_cast<void const*>( uintptr_t(buffer) + offset );
60 size -= offset; 60 size -= offset;
61 } 61 }
62 62
diff --git a/include/utils/KeyedVector.h b/include/utils/KeyedVector.h
index e3d19e1e8..92579e25f 100644
--- a/include/utils/KeyedVector.h
+++ b/include/utils/KeyedVector.h
@@ -157,7 +157,7 @@ template<typename KEY, typename VALUE> inline
157VALUE& KeyedVector<KEY,VALUE>::editValueFor(const KEY& key) { 157VALUE& KeyedVector<KEY,VALUE>::editValueFor(const KEY& key) {
158 ssize_t i = this->indexOfKey(key); 158 ssize_t i = this->indexOfKey(key);
159 LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); 159 LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__);
160 return mVector.editItemAt(i).value; 160 return mVector.editItemAt(static_cast<size_t>(i)).value;
161} 161}
162 162
163template<typename KEY, typename VALUE> inline 163template<typename KEY, typename VALUE> inline
diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h
index c6466d3f3..36016cde6 100644
--- a/include/utils/RefBase.h
+++ b/include/utils/RefBase.h
@@ -206,17 +206,29 @@ inline bool operator _op_ (const U* o) const { \
206 206
207// --------------------------------------------------------------------------- 207// ---------------------------------------------------------------------------
208 208
209// RefererenceRenamer is pure abstract, there is no virtual method
210// implementation to put in a translation unit in order to silence the
211// weak vtables warning.
212#if defined(__clang__)
213#pragma clang diagnostic push
214#pragma clang diagnostic ignored "-Wweak-vtables"
215#endif
216
209class ReferenceRenamer { 217class ReferenceRenamer {
210protected: 218protected:
211 // destructor is purposedly not virtual so we avoid code overhead from 219 // destructor is purposedly not virtual so we avoid code overhead from
212 // subclasses; we have to make it protected to guarantee that it 220 // subclasses; we have to make it protected to guarantee that it
213 // cannot be called from this base class (and to make strict compilers 221 // cannot be called from this base class (and to make strict compilers
214 // happy). 222 // happy).
215 ~ReferenceRenamer(); 223 ~ReferenceRenamer() { }
216public: 224public:
217 virtual void operator()(size_t i) const = 0; 225 virtual void operator()(size_t i) const = 0;
218}; 226};
219 227
228#if defined(__clang__)
229#pragma clang diagnostic pop
230#endif
231
220// --------------------------------------------------------------------------- 232// ---------------------------------------------------------------------------
221 233
222class RefBase 234class RefBase
diff --git a/include/utils/TypeHelpers.h b/include/utils/TypeHelpers.h
index 627579350..2a2522722 100644
--- a/include/utils/TypeHelpers.h
+++ b/include/utils/TypeHelpers.h
@@ -151,16 +151,21 @@ void destroy_type(TYPE* p, size_t n) {
151 } 151 }
152} 152}
153 153
154template<typename TYPE> inline 154template<typename TYPE>
155void copy_type(TYPE* d, const TYPE* s, size_t n) { 155typename std::enable_if<traits<TYPE>::has_trivial_copy>::type
156 if (!traits<TYPE>::has_trivial_copy) { 156inline
157 while (n > 0) { 157copy_type(TYPE* d, const TYPE* s, size_t n) {
158 n--; 158 memcpy(d,s,n*sizeof(TYPE));
159 new(d) TYPE(*s); 159}
160 d++, s++; 160
161 } 161template<typename TYPE>
162 } else { 162typename std::enable_if<!traits<TYPE>::has_trivial_copy>::type
163 memcpy(d,s,n*sizeof(TYPE)); 163inline
164copy_type(TYPE* d, const TYPE* s, size_t n) {
165 while (n > 0) {
166 n--;
167 new(d) TYPE(*s);
168 d++, s++;
164 } 169 }
165} 170}
166 171
diff --git a/include/utils/Vector.h b/include/utils/Vector.h
index 81ac9c7a1..b6d5686ac 100644
--- a/include/utils/Vector.h
+++ b/include/utils/Vector.h
@@ -194,7 +194,7 @@ public:
194 inline void push_back(const TYPE& item) { insertAt(item, size(), 1); } 194 inline void push_back(const TYPE& item) { insertAt(item, size(), 1); }
195 inline void push_front(const TYPE& item) { insertAt(item, 0, 1); } 195 inline void push_front(const TYPE& item) { insertAt(item, 0, 1); }
196 inline iterator erase(iterator pos) { 196 inline iterator erase(iterator pos) {
197 ssize_t index = removeItemsAt(pos-array()); 197 ssize_t index = removeItemsAt(static_cast<size_t>(pos-array()));
198 return begin() + index; 198 return begin() + index;
199 } 199 }
200 200