Fix more system/core/include warnings

The warnings in these files were hidden by -isystem
framework/native/include.

Bug: 31752268
Test: m -j
Change-Id: I2a54376aea380ee24e6483fb7d35fdfe8991c490
diff --git a/include/cutils/native_handle.h b/include/cutils/native_handle.h
index 268c5d3..31695cb 100644
--- a/include/cutils/native_handle.h
+++ b/include/cutils/native_handle.h
@@ -26,7 +26,14 @@
     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;
 
 /*
diff --git a/include/utils/Flattenable.h b/include/utils/Flattenable.h
index c37ac60..22b811a 100644
--- a/include/utils/Flattenable.h
+++ b/include/utils/Flattenable.h
@@ -31,32 +31,32 @@
 
 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;
     }
 
diff --git a/include/utils/KeyedVector.h b/include/utils/KeyedVector.h
index e3d19e1..92579e2 100644
--- a/include/utils/KeyedVector.h
+++ b/include/utils/KeyedVector.h
@@ -157,7 +157,7 @@
 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
diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h
index c6466d3..36016cd 100644
--- a/include/utils/RefBase.h
+++ b/include/utils/RefBase.h
@@ -206,17 +206,29 @@
 
 // ---------------------------------------------------------------------------
 
+// 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
diff --git a/include/utils/TypeHelpers.h b/include/utils/TypeHelpers.h
index 6275793..2a25227 100644
--- a/include/utils/TypeHelpers.h
+++ b/include/utils/TypeHelpers.h
@@ -151,16 +151,21 @@
     }
 }
 
-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++;
     }
 }
 
diff --git a/include/utils/Vector.h b/include/utils/Vector.h
index 81ac9c7..b6d5686 100644
--- a/include/utils/Vector.h
+++ b/include/utils/Vector.h
@@ -194,7 +194,7 @@
      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;
      }
 
diff --git a/libutils/RefBase.cpp b/libutils/RefBase.cpp
index ba1aaee..1f8395b 100644
--- a/libutils/RefBase.cpp
+++ b/libutils/RefBase.cpp
@@ -770,8 +770,6 @@
     ref->mRefs->renameWeakRefId(old_id, new_id);
 }
 
-ReferenceRenamer::~ReferenceRenamer() {}
-
 VirtualLightRefBase::~VirtualLightRefBase() {}
 
 }; // namespace android