crypto.c: modified if() check in ecryptfs_encrypt_and_encode_filename(). It 
will evaluate only once and we use that evaluation result again later instead 
of re-evaluating the condition.

Signed-off-by: Abhijit Pawar <[email protected]>
---
 fs/ecryptfs/crypto.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index ea99312..b5e4836 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -2086,6 +2086,7 @@ int ecryptfs_encrypt_and_encode_filename(
            || (mount_crypt_stat && (mount_crypt_stat->flags
                                     & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES))) {
                struct ecryptfs_filename *filename;
+               bool flag = false;
 
                filename = kzalloc(sizeof(*filename), GFP_KERNEL);
                if (!filename) {
@@ -2113,10 +2114,12 @@ int ecryptfs_encrypt_and_encode_filename(
                                    & ECRYPTFS_ENCFN_USE_MOUNT_FNEK))
                    || (mount_crypt_stat
                        && (mount_crypt_stat->flags
-                           & ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK)))
+                           & ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK))) {
                        (*encoded_name_size) =
                                (ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE
                                 + encoded_name_no_prefix_size);
+                       flag = true;
+               }
                else
                        (*encoded_name_size) =
                                (ECRYPTFS_FEK_ENCRYPTED_FILENAME_PREFIX_SIZE
@@ -2131,11 +2134,7 @@ int ecryptfs_encrypt_and_encode_filename(
                        kfree(filename);
                        goto out;
                }
-               if ((crypt_stat && (crypt_stat->flags
-                                   & ECRYPTFS_ENCFN_USE_MOUNT_FNEK))
-                   || (mount_crypt_stat
-                       && (mount_crypt_stat->flags
-                           & ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK))) {
+               if (flag) {
                        memcpy((*encoded_name),
                               ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX,
                               ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to