vold: Fix the compilation failure for cryptfs

Fixed compilation failures noticed when perf
flag (HW_DISK_ENCRYPT_PERF) is disabled.

CRs-Fixed: 2832825
Change-Id: Idbaf34a95ba30618c3a2dd91255f8dfceac81760
diff --git a/cryptfs.cpp b/cryptfs.cpp
index 496b356..5028829 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -1310,8 +1310,8 @@
 }
 
 static int create_crypto_blk_dev_hw(struct crypt_mnt_ftr* crypt_ftr, const unsigned char* master_key,
-                                 const char* real_blk_name, char* crypto_blk_name, const char* name,
-                                 uint32_t flags) {
+                                 const char* real_blk_name, std::string* crypto_blk_name,
+                                 const char* name, uint32_t flags) {
     char buffer[DM_CRYPT_BUF_SIZE];
     struct dm_ioctl* io;
     unsigned int minor;
@@ -1319,7 +1319,7 @@
     int err;
     int retval = -1;
     int version[3];
-    int load_count;
+    int load_count = 0;
     char encrypted_state[PROPERTY_VALUE_MAX] = {0};
     char progress[PROPERTY_VALUE_MAX] = {0};
     const char *extra_params;
@@ -1345,7 +1345,7 @@
         goto errout;
     }
     minor = (io->dev & 0xff) | ((io->dev >> 12) & 0xfff00);
-    snprintf(crypto_blk_name, MAXPATHLEN, "/dev/block/dm-%u", minor);
+    snprintf(crypto_blk_name->data(), MAXPATHLEN, "/dev/block/dm-%u", minor);
 
     if(is_hw_disk_encryption((char*)crypt_ftr->crypto_type_name)) {
       /* Set fde_enabled if either FDE completed or in-progress */
@@ -1380,7 +1380,7 @@
     }
 
     /* Ensure the dm device has been created before returning. */
-    if (android::vold::WaitForFile(crypto_blk_name, 1s) < 0) {
+    if (android::vold::WaitForFile(crypto_blk_name->c_str(), 1s) < 0) {
         // WaitForFile generates a suitable log message
         goto errout;
     }
@@ -2108,7 +2108,7 @@
 {
     /* Allocate enough space for a 256 bit key, but we may use less */
     unsigned char decrypted_master_key[32];
-    char crypto_blkdev_hw[MAXPATHLEN];
+    std::string crypto_blkdev_hw;
     std::string crypto_blkdev;
     std::string real_blkdev;
     unsigned int orig_failed_decrypt_count;
@@ -2130,7 +2130,7 @@
             if (is_ice_enabled()) {
 #ifndef CONFIG_HW_DISK_ENCRYPT_PERF
                 if (create_crypto_blk_dev_hw(crypt_ftr, (unsigned char*)&key_index,
-                                          real_blkdev.c_str(), crypto_blkdev_hw, label, 0)) {
+                                          real_blkdev.c_str(), &crypto_blkdev_hw, label, 0)) {
                     SLOGE("Error creating decrypted block device");
                     rc = -1;
                     goto errout;
@@ -2155,12 +2155,13 @@
 
         /* Save the name of the crypto block device
          * so we can mount it when restarting the framework. */
-#ifdef CONFIG_HW_DISK_ENCRYPT_PERF
-        if (!is_ice_enabled())
-        property_set("ro.crypto.fs_crypto_blkdev", crypto_blkdev_hw);
-#else
-        property_set("ro.crypto.fs_crypto_blkdev", crypto_blkdev);
+        if (is_ice_enabled()) {
+#ifndef CONFIG_HW_DISK_ENCRYPT_PERF
+            property_set("ro.crypto.fs_crypto_blkdev", crypto_blkdev_hw.c_str());
 #endif
+        } else {
+            property_set("ro.crypto.fs_crypto_blkdev", crypto_blkdev.c_str());
+        }
         master_key_saved = 1;
     }