resolved conflicts for merge of 83755972 to klp-modular-dev-plus-aosp

Change-Id: I4bf4dd29a65f82f91738526b80d5b579c26f8bfe
diff --git a/CommandListener.cpp b/CommandListener.cpp
index 049d42c..ea18c1d 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -54,8 +54,8 @@
     registerCmd(new FstrimCmd());
 }
 
-void CommandListener::dumpArgs(int argc, char **argv, int argObscure) {
 #if DUMP_ARGS
+void CommandListener::dumpArgs(int argc, char **argv, int argObscure) {
     char buffer[4096];
     char *p = buffer;
 
@@ -81,15 +81,17 @@
         }
     }
     SLOGD("%s", buffer);
-#endif
 }
+#else
+void CommandListener::dumpArgs(int /*argc*/, char ** /*argv*/, int /*argObscure*/) { }
+#endif
 
 CommandListener::DumpCmd::DumpCmd() :
                  VoldCommand("dump") {
 }
 
 int CommandListener::DumpCmd::runCommand(SocketClient *cli,
-                                         int argc, char **argv) {
+                                         int /*argc*/, char ** /*argv*/) {
     cli->sendMsg(0, "Dumping loop status", false);
     if (Loop::dumpState(cli)) {
         cli->sendMsg(ResponseCode::CommandOkay, "Loop dump failed", true);
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index 960eef6..67f89ea 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -151,7 +151,8 @@
     return -1;
 }
 
-void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
+void DirectVolume::handleDiskAdded(const char * /*devpath*/,
+                                   NetlinkEvent *evt) {
     mDiskMajor = atoi(evt->findParam("MAJOR"));
     mDiskMinor = atoi(evt->findParam("MINOR"));
 
@@ -240,7 +241,8 @@
     }
 }
 
-void DirectVolume::handleDiskChanged(const char *devpath, NetlinkEvent *evt) {
+void DirectVolume::handleDiskChanged(const char * /*devpath*/,
+                                     NetlinkEvent *evt) {
     int major = atoi(evt->findParam("MAJOR"));
     int minor = atoi(evt->findParam("MINOR"));
 
@@ -273,13 +275,15 @@
     }
 }
 
-void DirectVolume::handlePartitionChanged(const char *devpath, NetlinkEvent *evt) {
+void DirectVolume::handlePartitionChanged(const char * /*devpath*/,
+                                          NetlinkEvent *evt) {
     int major = atoi(evt->findParam("MAJOR"));
     int minor = atoi(evt->findParam("MINOR"));
     SLOGD("Volume %s %s partition %d:%d changed\n", getLabel(), getMountpoint(), major, minor);
 }
 
-void DirectVolume::handleDiskRemoved(const char *devpath, NetlinkEvent *evt) {
+void DirectVolume::handleDiskRemoved(const char * /*devpath*/,
+                                     NetlinkEvent *evt) {
     int major = atoi(evt->findParam("MAJOR"));
     int minor = atoi(evt->findParam("MINOR"));
     char msg[255];
@@ -297,7 +301,8 @@
     setState(Volume::State_NoMedia);
 }
 
-void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt) {
+void DirectVolume::handlePartitionRemoved(const char * /*devpath*/,
+                                          NetlinkEvent *evt) {
     int major = atoi(evt->findParam("MAJOR"));
     int minor = atoi(evt->findParam("MINOR"));
     char msg[255];
diff --git a/Loop.cpp b/Loop.cpp
index 78df132..3f0ee1e 100644
--- a/Loop.cpp
+++ b/Loop.cpp
@@ -227,7 +227,7 @@
     return 0;
 }
 
-int Loop::destroyByFile(const char *loopFile) {
+int Loop::destroyByFile(const char * /*loopFile*/) {
     errno = ENOSYS;
     return -1;
 }
diff --git a/Volume.cpp b/Volume.cpp
index c290200..ca56d1c 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -147,7 +147,7 @@
 void Volume::handleVolumeUnshared() {
 }
 
-int Volume::handleBlockEvent(NetlinkEvent *evt) {
+int Volume::handleBlockEvent(NetlinkEvent * /*evt*/) {
     errno = ENOSYS;
     return -1;
 }
@@ -378,14 +378,14 @@
 
        if (n != 1) {
            /* We only expect one device node returned when mounting encryptable volumes */
-           SLOGE("Too many device nodes returned when mounting %d\n", getMountpoint());
+           SLOGE("Too many device nodes returned when mounting %s\n", getMountpoint());
            return -1;
        }
 
        if (cryptfs_setup_volume(getLabel(), MAJOR(deviceNodes[0]), MINOR(deviceNodes[0]),
                                 new_sys_path, sizeof(new_sys_path),
                                 &new_major, &new_minor)) {
-           SLOGE("Cannot setup encryption mapping for %d\n", getMountpoint());
+           SLOGE("Cannot setup encryption mapping for %s\n", getMountpoint());
            return -1;
        }
        /* We now have the new sysfs path for the decrypted block device, and the
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index e8842fa..1ffa939 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -93,7 +93,7 @@
         errno = ESPIPE;
         return NULL;
     } else if (len < MD5_ASCII_LENGTH_PLUS_NULL) {
-        SLOGE("Target hash buffer size < %d bytes (%d)",
+        SLOGE("Target hash buffer size < %d bytes (%zu)",
                 MD5_ASCII_LENGTH_PLUS_NULL, len);
         errno = ESPIPE;
         return NULL;
@@ -646,7 +646,7 @@
                 result |= fchmod(fd, privateFile ? 0640 : 0644);
             }
 
-            if (selinux_android_restorecon(ftsent->fts_path) < 0) {
+            if (selinux_android_restorecon(ftsent->fts_path, 0) < 0) {
                 SLOGE("restorecon failed for %s: %s\n", ftsent->fts_path, strerror(errno));
                 result |= -1;
             }
@@ -1036,7 +1036,7 @@
 
     int written = snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id);
     if ((written < 0) || (size_t(written) >= sizeof(mountPoint))) {
-        SLOGE("ASEC mount failed: couldn't construct mountpoint", id);
+        SLOGE("ASEC mount failed for %s: couldn't construct mountpoint", id);
         return -1;
     }
 
@@ -1183,7 +1183,7 @@
 
     int written = snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::LOOPDIR, idHash);
     if ((written < 0) || (size_t(written) >= sizeof(mountPoint))) {
-        SLOGE("OBB mount failed: couldn't construct mountpoint", img);
+        SLOGE("OBB mount failed for %s: couldn't construct mountpoint", img);
         return -1;
     }
 
diff --git a/cryptfs.c b/cryptfs.c
index 6247014..e545919 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -50,6 +50,8 @@
 #include "VoldUtil.h"
 #include "crypto_scrypt.h"
 
+#define UNUSED __attribute__((unused))
+
 #define DM_CRYPT_BUF_SIZE 4096
 #define DATA_MNT_POINT "/data"
 
@@ -276,7 +278,7 @@
   /* If the keys are kept on a raw block device, do not try to truncate it. */
   if (S_ISREG(statbuf.st_mode)) {
     if (ftruncate(fd, 0x4000)) {
-      SLOGE("Cannot set footer file size\n", fname);
+      SLOGE("Cannot set footer file size\n");
       goto errout;
     }
   }
@@ -868,7 +870,7 @@
 
 }
 
-static void pbkdf2(char *passwd, unsigned char *salt, unsigned char *ikey, void *params) {
+static void pbkdf2(char *passwd, unsigned char *salt, unsigned char *ikey, void *params UNUSED) {
     /* Turn the password into a key and IV that can decrypt the master key */
     PKCS5_PBKDF2_HMAC_SHA1(passwd, strlen(passwd), salt, SALT_LEN,
                            HASH_COUNT, KEY_LEN_BYTES+IV_LEN_BYTES, ikey);
@@ -1150,7 +1152,7 @@
     return rc;
 }
 
-static int do_crypto_complete(char *mount_point)
+static int do_crypto_complete(char *mount_point UNUSED)
 {
   struct crypt_mnt_ftr crypt_ftr;
   char encrypted_state[PROPERTY_VALUE_MAX];
diff --git a/cryptfs.h b/cryptfs.h
index 162159e..bd44dfa 100644
--- a/cryptfs.h
+++ b/cryptfs.h
@@ -56,8 +56,7 @@
 #define KDF_PBKDF2 1
 #define KDF_SCRYPT 2
 
-#define __le32 unsigned int
-#define __le16 unsigned short int
+/* __le32 and __le16 defined in system/extras/ext4_utils/ext4_utils.h */
 #define __le8  unsigned char
 
 struct crypt_mnt_ftr {
diff --git a/fstrim.c b/fstrim.c
index 2bd0577..9a6637d 100644
--- a/fstrim.c
+++ b/fstrim.c
@@ -37,6 +37,8 @@
 
 #define FSTRIM_WAKELOCK "dofstrim"
 
+#define UNUSED __attribute__((unused))
+
 static unsigned long long get_boot_time_ms(void)
 {
     struct timespec t;
@@ -50,7 +52,7 @@
     return time_ms;
 }
 
-static void *do_fstrim_filesystems(void *ignored)
+static void *do_fstrim_filesystems(void *ignored UNUSED)
 {
     int i;
     int fd;