diff --git a/crypto/fde/cryptfs.cpp b/crypto/fde/cryptfs.cpp
index 5b8757c..8352296 100644
--- a/crypto/fde/cryptfs.cpp
+++ b/crypto/fde/cryptfs.cpp
@@ -256,7 +256,7 @@
 
     if (should_use_keymaster()) {
         if (scrypt_keymaster(passwd, salt, newpw, (void*)ftr)) {
-            SLOGE("scrypt failed\n");
+            SLOGE("scrypt failed");
         } else {
             rc = 0;
         }
@@ -293,7 +293,7 @@
         ++crypt_ftr->failed_decrypt_count;
 
         if (ascii_passwd_updated) {
-            SLOGI("Ascii password was updated\n");
+            SLOGI("Ascii password was updated");
         } else {
             /* Code in else part would execute only once:
              * When device is upgraded from L->M release.
@@ -305,14 +305,14 @@
             if (crypt_ftr->crypt_type == CRYPT_TYPE_DEFAULT) {
                 new_passwd = (char*)malloc(strlen(DEFAULT_HEX_PASSWORD) + 1);
                 if (new_passwd == NULL) {
-                    SLOGE("System out of memory. Password verification  incomplete\n");
+                    SLOGE("System out of memory. Password verification  incomplete");
                     goto out;
                 }
                 strlcpy(new_passwd, DEFAULT_HEX_PASSWORD, strlen(DEFAULT_HEX_PASSWORD) + 1);
             } else {
                 new_passwd = (char*)malloc(strlen(passwd) * 2 + 1);
                 if (new_passwd == NULL) {
-                    SLOGE("System out of memory. Password verification  incomplete\n");
+                    SLOGE("System out of memory. Password verification  incomplete");
                     goto out;
                 }
                 convert_key_to_hex_ascii_for_upgrade((const unsigned char*)passwd,
@@ -322,7 +322,7 @@
                                        (char*) crypt_ftr->crypto_type_name);
             if (key_index >=0) {
                 crypt_ftr->failed_decrypt_count = 0;
-                SLOGI("Hex password verified...will try to update with Ascii value\n");
+                SLOGI("Hex password verified...will try to update with Ascii value");
                 /* Before updating password, tie that with keymaster to tie with ROT */
 
                 if (get_keymaster_hw_fde_passwd(passwd, newpw,
@@ -336,9 +336,9 @@
 
                 if (passwd_updated >= 0) {
                     crypt_ftr->flags |= CRYPT_ASCII_PASSWORD_UPDATED;
-                    SLOGI("Ascii password recorded and updated\n");
+                    SLOGI("Ascii password recorded and updated");
                 } else {
-                    SLOGI("Passwd verified, could not update...Will try next time\n");
+                    SLOGI("Passwd verified, could not update...Will try next time");
                 }
             } else {
                 ++crypt_ftr->failed_decrypt_count;
@@ -412,10 +412,10 @@
             // so) because we really should be using a proper deterministic
             // RSA padding function, such as PKCS1.
             memcpy(to_sign + 1, object, min((size_t)RSA_KEY_SIZE_BYTES - 1, object_size));
-            SLOGI("Signing safely-padded object\n");
+            SLOGI("Signing safely-padded object");
             break;
         default:
-            SLOGE("Unknown KDF type %d\n", ftr->kdf_type);
+            SLOGE("Unknown KDF type %d", ftr->kdf_type);
             return -1;
     }
 
@@ -549,7 +549,7 @@
             return -1;
         }
         /*if (put_crypt_ftr_and_key(ftr) != 0) {
-            SLOGE("Failed to write upgraded key to disk\n");
+            SLOGE("Failed to write upgraded key to disk");
         }*/
         SLOGD("Key upgraded successfully\n");
         return 0;
@@ -930,8 +930,8 @@
            crypt_ftr->crypto_type_name, master_key_ascii,
            real_blk_name, extra_params);
 
-  SLOGI("target_type = %s\n", tgt->target_type);
-  SLOGI("real_blk_name = %s, extra_params = %s\n", real_blk_name, extra_params);
+  SLOGI("target_type = %s", tgt->target_type);
+  SLOGI("real_blk_name = %s, extra_params = %s", real_blk_name, extra_params);
 #else
   convert_key_to_hex_ascii(master_key, crypt_ftr->keysize, master_key_ascii);
   strlcpy(tgt->target_type, "crypt", DM_MAX_TYPE_NAME);
@@ -1205,13 +1205,13 @@
                        INTERMEDIATE_BUF_SIZE);
 
     if (rc) {
-        SLOGE("scrypt failed\n");
+        SLOGE("scrypt failed");
         return -1;
     }
 
     if (keymaster_sign_object(ftr, ikey, INTERMEDIATE_BUF_SIZE,
                               &signature, &signature_size)) {
-        SLOGE("Keymaster signing failed\n");
+        SLOGE("Keymaster signing failed");
         return -1;
     }
 
@@ -1220,7 +1220,7 @@
     free(signature);
 
     if (rc) {
-        SLOGE("scrypt failed\n");
+        SLOGE("scrypt failed");
         return -1;
     }
 
@@ -1242,7 +1242,7 @@
   /* Turn the password into an intermediate key and IV that can decrypt the
      master key */
   if (kdf(passwd, salt, ikey, kdf_params)) {
-    SLOGE("kdf failed\n");
+    SLOGE("kdf failed");
     return -1;
   }
 
@@ -1308,7 +1308,7 @@
                                  decrypted_master_key, kdf, kdf_params,
                                  intermediate_key, intermediate_key_size);
     if (ret != 0) {
-        SLOGW("failure decrypting master key\n");
+        SLOGW("failure decrypting master key");
     }
 
     return ret;
@@ -1332,13 +1332,6 @@
 
   int key_index = 0;
   if(is_hw_disk_encryption((char*)crypt_ftr->crypto_type_name)) {
-    if (crypt_ftr->flags & CRYPT_FORCE_COMPLETE) {
-       if (decrypt_master_key(passwd, decrypted_master_key, crypt_ftr, 0, 0)) {
-           printf("Failed to decrypt master key\n");
-           rc = -1;
-           goto errout;
-       }
-    }
     key_index = verify_and_update_hw_fde_passwd(passwd, crypt_ftr);
     if (key_index < 0) {
       rc = -1;
@@ -1349,7 +1342,7 @@
 #ifndef CONFIG_HW_DISK_ENCRYPT_PERF
         if (create_crypto_blk_dev(crypt_ftr, (unsigned char*)&key_index,
                             real_blkdev, crypto_blkdev, label, 0)) {
-          SLOGE("Error creating decrypted block device\n");
+          SLOGE("Error creating decrypted block device");
           rc = -1;
           goto errout;
         }
@@ -1357,7 +1350,7 @@
       } else {
         if (create_crypto_blk_dev(crypt_ftr, decrypted_master_key,
                             real_blkdev, crypto_blkdev, label, 0)) {
-          SLOGE("Error creating decrypted block device\n");
+          SLOGE("Error creating decrypted block device");
           rc = -1;
           goto errout;
         }
@@ -1403,7 +1396,7 @@
   //char real_blkdev[MAXPATHLEN];
   char tmp_mount_point[64];
   unsigned int orig_failed_decrypt_count;
-  int rc = 0;
+  int rc;
   int use_keymaster = 0;
   unsigned char* intermediate_key = 0;
   size_t intermediate_key_size = 0;
@@ -1446,7 +1439,7 @@
   if (rc == 0 && memcmp(scrypted_intermediate_key,
                         crypt_ftr->scrypted_intermediate_key,
                         sizeof(scrypted_intermediate_key)) == 0) {
-    SLOGI("Password matches\n");
+    SLOGI("Password matches");
     rc = 0;
   } else {
     /* Try mounting the file system anyway, just in case the problem's with
@@ -1461,7 +1454,7 @@
       rc = -1;
     } else {
       /* Success! */
-      SLOGI("Password did not match but decrypted drive mounted - continue\n");
+      SLOGI("Password did not match but decrypted drive mounted - continue");
       umount(tmp_mount_point);
       rc = 0;
     }
@@ -1501,7 +1494,7 @@
         const unsigned char* key, int keysize, char* out_crypto_blkdev) {
     int fd = open(real_blkdev, O_RDONLY|O_CLOEXEC);
     if (fd == -1) {
-        SLOGE("Failed to open %s: %s\n", real_blkdev, strerror(errno));
+        SLOGE("Failed to open %s: %s", real_blkdev, strerror(errno));
         return -1;
     }
 
@@ -1510,7 +1503,7 @@
     close(fd);
 
     if (nr_sec == 0) {
-        SLOGE("Failed to get size of %s: %s\n", real_blkdev, strerror(errno));
+        SLOGE("Failed to get size of %s: %s", real_blkdev, strerror(errno));
         return -1;
     }
 
@@ -1542,12 +1535,12 @@
     property_get("ro.crypto.state", encrypted_state, "");
     if ( master_key_saved || strcmp(encrypted_state, "encrypted") ) {
         SLOGE("encrypted fs already validated or not running with encryption,"
-              " aborting\n");
+              " aborting");
         return -1;
     }
 
     if (get_crypt_ftr_and_key(crypt_ftr)) {
-        SLOGE("Error getting crypt footer and key\n");
+        SLOGE("Error getting crypt footer and key");
         return -1;
     }
 
@@ -1558,11 +1551,11 @@
 int cryptfs_check_passwd_hw(const char* passwd)
 {
     struct crypt_mnt_ftr crypt_ftr;
-    int rc = 0;
+    int rc;
     unsigned char master_key[KEY_LEN_BYTES];
     /* get key */
     if (get_crypt_ftr_and_key(&crypt_ftr)) {
-        SLOGE("Error getting crypt footer and key\n");
+        SLOGE("Error getting crypt footer and key");
         return -1;
     }
 
@@ -1576,7 +1569,7 @@
          */
         rc = cryptfs_get_master_key(&crypt_ftr, passwd, master_key);
         if (rc) {
-            SLOGE("password doesn't match\n");
+            SLOGE("password doesn't match");
             return rc;
         }
 
@@ -1584,7 +1577,7 @@
             DATA_MNT_POINT, CRYPTO_BLOCK_DEVICE);
 
         if (rc) {
-            SLOGE("Default password did not match on reboot encryption\n");
+            SLOGE("Default password did not match on reboot encryption");
             return rc;
         }
     } else {
@@ -1600,7 +1593,7 @@
 int cryptfs_check_passwd(const char *passwd)
 {
     /*if (e4crypt_is_native()) {
-        SLOGE("cryptfs_check_passwd not valid for file encryption\n");
+        SLOGE("cryptfs_check_passwd not valid for file encryption");
         return -1;
     }*/
 
@@ -1609,7 +1602,7 @@
 
     rc = check_unmounted_and_get_ftr(&crypt_ftr);
     if (rc) {
-        SLOGE("Could not get footer\n");
+        SLOGE("Could not get footer");
         return rc;
     }
 
@@ -1622,7 +1615,7 @@
                                  DATA_MNT_POINT, CRYPTO_BLOCK_DEVICE);
 
     if (rc) {
-        SLOGE("Password did not match\n");
+        SLOGE("Password did not match");
         return rc;
     }
 
@@ -1635,7 +1628,7 @@
         rc = test_mount_encrypted_fs(&crypt_ftr, DEFAULT_PASSWORD,
                                      DATA_MNT_POINT, CRYPTO_BLOCK_DEVICE);
         if (rc) {
-            SLOGE("Default password did not match on reboot encryption\n");
+            SLOGE("Default password did not match on reboot encryption");
             return rc;
         }
     }
@@ -1652,17 +1645,17 @@
 
     property_get("ro.crypto.state", encrypted_state, "");
     if (strcmp(encrypted_state, "encrypted") ) {
-        SLOGE("device not encrypted, aborting\n");
+        SLOGE("device not encrypted, aborting");
         return -2;
     }
 
     if (!master_key_saved) {
-        SLOGE("encrypted fs not yet mounted, aborting\n");
+        SLOGE("encrypted fs not yet mounted, aborting");
         return -1;
     }
 
     if (!saved_mount_point) {
-        SLOGE("encrypted fs failed to save mount point, aborting\n");
+        SLOGE("encrypted fs failed to save mount point, aborting");
         return -1;
     }
 
@@ -1742,7 +1735,7 @@
                             &intermediate_key_size);
 
     if (rc) {
-        SLOGE("Can't calculate intermediate key\n");
+        SLOGE("Can't calculate intermediate key");
         return rc;
     }
 
@@ -1760,7 +1753,7 @@
     free(intermediate_key);
 
     if (rc) {
-        SLOGE("Can't scrypt intermediate key\n");
+        SLOGE("Can't scrypt intermediate key");
         return rc;
     }
 
