Don\'t fail if a key we want to delete is already deleted
am: ab0b56aef3

Change-Id: I08920a3e330443e7466f0acc924cd21dbebba4c4
diff --git a/Android.mk b/Android.mk
index cabf9b3..4cd3dd0 100644
--- a/Android.mk
+++ b/Android.mk
@@ -51,6 +51,7 @@
 	liblogwrap \
 	libext4_utils \
 	libf2fs_sparseblock \
+	libcrypto_utils \
 	libcrypto \
 	libselinux \
 	libutils \
@@ -66,7 +67,6 @@
 	libfec_rs \
 	libsquashfs_utils \
 	libscrypt_static \
-	libmincrypt \
 	libbatteryservice \
 
 vold_conlyflags := -std=c11
diff --git a/MoveTask.cpp b/MoveTask.cpp
index a0522d2..0a60c4e 100644
--- a/MoveTask.cpp
+++ b/MoveTask.cpp
@@ -27,7 +27,7 @@
 #include <dirent.h>
 #include <sys/wait.h>
 
-#define CONSTRAIN(amount, low, high) (amount < low ? low : (amount > high ? high : amount))
+#define CONSTRAIN(amount, low, high) ((amount) < (low) ? (low) : ((amount) > (high) ? (high) : (amount)))
 
 using android::base::StringPrintf;
 
diff --git a/Utils.cpp b/Utils.cpp
index 014055b..62c7ef6 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -211,7 +211,7 @@
     for (auto line : output) {
         // Extract values from blkid output, if defined
         const char* cline = line.c_str();
-        char* start = strstr(cline, "TYPE=");
+        const char* start = strstr(cline, "TYPE=");
         if (start != nullptr && sscanf(start + 5, "\"%127[^\"]\"", value) == 1) {
             fsType = value;
         }
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 5cc60a1..e1ee96c 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -63,8 +63,8 @@
 
 #define MASS_STORAGE_FILE_PATH  "/sys/class/android_usb/android0/f_mass_storage/lun/file"
 
-#define ROUND_UP_POWER_OF_2(number, po2) (((!!(number & ((1U << po2) - 1))) << po2)\
-                                         + (number & (~((1U << po2) - 1))))
+#define ROUND_UP_POWER_OF_2(number, po2) (((!!((number) & ((1U << (po2)) - 1))) << (po2))\
+                                         + ((number) & (~((1U << (po2)) - 1))))
 
 using android::base::StringPrintf;
 
diff --git a/VolumeManager.h b/VolumeManager.h
index 39fc8f9..dd9f09d 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -217,7 +217,7 @@
 
 extern "C" {
 #endif /* __cplusplus */
-#define UNMOUNT_NOT_MOUNTED_ERR -2
+#define UNMOUNT_NOT_MOUNTED_ERR (-2)
     int vold_unmountAll(void);
 #ifdef __cplusplus
 }
diff --git a/cryptfs.h b/cryptfs.h
index 11d9bb7..bf158de 100644
--- a/cryptfs.h
+++ b/cryptfs.h
@@ -191,32 +191,32 @@
 /* Return values for cryptfs_crypto_complete */
 #define CRYPTO_COMPLETE_NOT_ENCRYPTED  1
 #define CRYPTO_COMPLETE_ENCRYPTED      0
-#define CRYPTO_COMPLETE_BAD_METADATA  -1
-#define CRYPTO_COMPLETE_PARTIAL       -2
-#define CRYPTO_COMPLETE_INCONSISTENT  -3
-#define CRYPTO_COMPLETE_CORRUPT       -4
+#define CRYPTO_COMPLETE_BAD_METADATA  (-1)
+#define CRYPTO_COMPLETE_PARTIAL       (-2)
+#define CRYPTO_COMPLETE_INCONSISTENT  (-3)
+#define CRYPTO_COMPLETE_CORRUPT       (-4)
 
 /* Return values for cryptfs_enable_inplace*() */
 #define ENABLE_INPLACE_OK 0
-#define ENABLE_INPLACE_ERR_OTHER -1
-#define ENABLE_INPLACE_ERR_DEV -2  /* crypto_blkdev issue */
+#define ENABLE_INPLACE_ERR_OTHER (-1)
+#define ENABLE_INPLACE_ERR_DEV (-2)  /* crypto_blkdev issue */
 
 /* Return values for cryptfs_getfield */
 #define CRYPTO_GETFIELD_OK                   0
-#define CRYPTO_GETFIELD_ERROR_NO_FIELD      -1
-#define CRYPTO_GETFIELD_ERROR_OTHER         -2
-#define CRYPTO_GETFIELD_ERROR_BUF_TOO_SMALL -3
+#define CRYPTO_GETFIELD_ERROR_NO_FIELD      (-1)
+#define CRYPTO_GETFIELD_ERROR_OTHER         (-2)
+#define CRYPTO_GETFIELD_ERROR_BUF_TOO_SMALL (-3)
 
 /* Return values for cryptfs_setfield */
 #define CRYPTO_SETFIELD_OK                    0
-#define CRYPTO_SETFIELD_ERROR_OTHER          -1
-#define CRYPTO_SETFIELD_ERROR_FIELD_TOO_LONG -2
-#define CRYPTO_SETFIELD_ERROR_VALUE_TOO_LONG -3
+#define CRYPTO_SETFIELD_ERROR_OTHER          (-1)
+#define CRYPTO_SETFIELD_ERROR_FIELD_TOO_LONG (-2)
+#define CRYPTO_SETFIELD_ERROR_VALUE_TOO_LONG (-3)
 
 /* Return values for persist_del_key */
 #define PERSIST_DEL_KEY_OK                 0
-#define PERSIST_DEL_KEY_ERROR_OTHER       -1
-#define PERSIST_DEL_KEY_ERROR_NO_FIELD    -2
+#define PERSIST_DEL_KEY_ERROR_OTHER       (-1)
+#define PERSIST_DEL_KEY_ERROR_NO_FIELD    (-2)
 
 #ifdef __cplusplus
 extern "C" {