Merge "libdex: Enable -Wimplicit-fallthrough"
diff --git a/dexdump/DexDump.cpp b/dexdump/DexDump.cpp
index 4971c21..9b1ac3a 100644
--- a/dexdump/DexDump.cpp
+++ b/dexdump/DexDump.cpp
@@ -128,8 +128,7 @@
 /*
  * Converts a type descriptor to human-readable "dotted" form.  For
  * example, "Ljava/lang/String;" becomes "java.lang.String", and
- * "[I" becomes "int[]".  Also converts '$' to '.', which means this
- * form can't be converted back to a descriptor.
+ * "[I" becomes "int[]".
  */
 static char* descriptorToDot(const char* str)
 {
@@ -166,7 +165,7 @@
     int i;
     for (i = 0; i < targetLen; i++) {
         char ch = str[offset + i];
-        newStr[i] = (ch == '/' || ch == '$') ? '.' : ch;
+        newStr[i] = (ch == '/') ? '.' : ch;
     }
 
     /* add the appropriate number of brackets for arrays */
@@ -181,16 +180,14 @@
 }
 
 /*
- * Converts the class name portion of a type descriptor to human-readable
- * "dotted" form.
+ * Retrieves the class name portion of a type descriptor.
  *
  * Returns a newly-allocated string.
  */
-static char* descriptorClassToDot(const char* str)
+static char* descriptorClassToName(const char* str)
 {
     const char* lastSlash;
     char* newStr;
-    char* cp;
 
     /* reduce to just the class name, trimming trailing ';' */
     lastSlash = strrchr(str, '/');
@@ -201,10 +198,6 @@
 
     newStr = strdup(lastSlash);
     newStr[strlen(lastSlash)-1] = '\0';
-    for (cp = newStr; *cp != '\0'; cp++) {
-        if (*cp == '$')
-            *cp = '.';
-    }
 
     return newStr;
 }
@@ -1325,7 +1318,7 @@
         if (constructor) {
             char* tmp;
 
-            tmp = descriptorClassToDot(backDescriptor);
+            tmp = descriptorClassToName(backDescriptor);
             printf("<constructor name=\"%s\"\n", tmp);
             free(tmp);
 
@@ -1590,7 +1583,7 @@
     } else {
         char* tmp;
 
-        tmp = descriptorClassToDot(classDescriptor);
+        tmp = descriptorClassToName(classDescriptor);
         printf("<class name=\"%s\"\n", tmp);
         free(tmp);
 
diff --git a/libdex/Android.bp b/libdex/Android.bp
index 2a443b9..ad0128b 100644
--- a/libdex/Android.bp
+++ b/libdex/Android.bp
@@ -38,7 +38,6 @@
     include_dirs: [
         "dalvik",
         "external/zlib",
-        "external/safe-iop/include",
     ],
     static_libs: ["liblog"],
     whole_static_libs: ["libziparchive"],
diff --git a/libdex/DexDataMap.cpp b/libdex/DexDataMap.cpp
index 65da14c..18e4a45 100644
--- a/libdex/DexDataMap.cpp
+++ b/libdex/DexDataMap.cpp
@@ -19,7 +19,6 @@
  */
 
 #include "DexDataMap.h"
-#include <safe_iop.h>
 #include <stdlib.h>
 
 /*
@@ -27,18 +26,15 @@
  */
 DexDataMap* dexDataMapAlloc(u4 maxCount) {
     /*
-     * Allocate a single chunk for the DexDataMap per se as well as the
+     * Allocate a single chunk for the DexDataMap itself as well as the
      * two arrays.
      */
     size_t size = 0;
     DexDataMap* map = NULL;
 
-    /*
-     * Avoiding pulling in safe_iop for safe_iopf.
-     */
     const u4 sizeOfItems = (u4) (sizeof(u4) + sizeof(u2));
-    if (!safe_mul(&size, maxCount, sizeOfItems) ||
-        !safe_add(&size, size, sizeof(DexDataMap))) {
+    if (__builtin_mul_overflow(maxCount, sizeOfItems, &size) ||
+        __builtin_add_overflow(size, sizeof(DexDataMap), &size)) {
       return NULL;
     }
 
diff --git a/libdex/DexSwapVerify.cpp b/libdex/DexSwapVerify.cpp
index 5d55fe4..d756dc4 100644
--- a/libdex/DexSwapVerify.cpp
+++ b/libdex/DexSwapVerify.cpp
@@ -25,7 +25,6 @@
 #include "DexUtf.h"
 #include "Leb128.h"
 
-#include <safe_iop.h>
 #include <zlib.h>
 
 #include <stdlib.h>
@@ -140,7 +139,8 @@
 #define CHECK_LIST_SIZE(_ptr, _count, _elemSize) {                          \
         const u1* _start = (const u1*) (_ptr);                              \
         const u1* _end = _start + ((_count) * (_elemSize));                 \
-        if (!safe_mul(nullptr, (_count), (_elemSize)) ||                    \
+        u4 _dummy;                                                          \
+        if (__builtin_mul_overflow((_count), (_elemSize), &_dummy) ||       \
             !checkPtrRange(state, _start, _end, #_ptr)) {                   \
             return 0;                                                       \
         }                                                                   \