eCryptfs: Remove redundant IF statement
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/3 eCryptfs: Remove redundant IF statement
ecryptfs_write_begin(mmap.c)
1 ...
2 if (index != 0) {
3 if (prev_page_end_size > i_size_read(page->mapping->host)) {
4 ...
5 }
6 ...
7 }
The IF statement in line 2 is redundant since the IF statement in line 3 deduces that.
--- fs/ecryptfs/mmap.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
fs/ecryptfs/mmap.c +1 -3
@@ -368,8 +368,7 @@ static int ecryptfs_write_begin(struct file *file, }/* If creating a page or more of holes, zero them out via truncate. * Note, this will increase i_size. */ -if (index !=0 ) { -if (prev_page_end_size >i_size_read (page->mapping->host)) { +if (prev_page_end_size >i_size_read (page->mapping->host)) { rc =ecryptfs_truncate (file->f_path.dentry, prev_page_end_size);if (rc) {
@@ -379,7 +378,6 @@ static int ecryptfs_write_begin(struct file *file, prev_page_end_size, rc); goto out; } - } } out:if (unlikely (rc)) {
Signature · 1 line
1.7.6.5
PATCH 2/3 eCryptfs: Remove redundant IF statement
In reply to a message not in the archiveecryptfs_write_begin(mmap.c)
1 ...
2 if (index != 0) {
3 if (prev_page_end_size > i_size_read(page->mapping->host)) {
4 ...
5 }
6 ...
7 }
The IF statement in line 2 is redundant since the IF statement in line 3 deduces that.
--- fs/ecryptfs/mmap.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
fs/ecryptfs/mmap.c +1 -3
@@ -368,8 +368,7 @@ static int ecryptfs_write_begin(struct file *file, }/* If creating a page or more of holes, zero them out via truncate. * Note, this will increase i_size. */ -if (index !=0 ) { -if (prev_page_end_size >i_size_read (page->mapping->host)) { +if (prev_page_end_size >i_size_read (page->mapping->host)) { rc =ecryptfs_truncate (file->f_path.dentry, prev_page_end_size);if (rc) {
@@ -379,7 +378,6 @@ static int ecryptfs_write_begin(struct file *file, prev_page_end_size, rc); goto out; } - } } out:if (unlikely (rc)) {
Signature · 1 line
1.7.6.5
PATCH 3/3 eCryptfs: Remove unreached codes
In reply to a message not in the archiveThe code segment handles the ECRYPTFS_VIEW_AS_ENCRYPTED option in ecryptfs_write_begin(mmap.c) is unreached, since this option is enabled only when eCryptfs is mounted with RDONLY.
--- fs/ecryptfs/mmap.c | 29 +---------------------------- 1 files changed, 1 insertions(+), 28 deletions(-)
fs/ecryptfs/mmap.c +1 -28
@@ -320,35 +320,8 @@ static int ecryptfs_write_begin(struct file *file, goto out; }else SetPageUptodate (page); - }else if (crypt_stat->flags &ECRYPTFS_VIEW_AS_ENCRYPTED ) { -if (crypt_stat->flags &ECRYPTFS_METADATA_IN_XATTR ) { - rc =ecryptfs_copy_up_encrypted_with_header ( - page, crypt_stat); -if (rc) { -printk (KERN_ERR "%s: Error attempting " -"to copy the encrypted content " -"from the lower file whilst " -"inserting the metadata from " -"the xattr into the header; rc " -"= [%d]\n" , __func__, rc); -ClearPageUptodate (page); - goto out; - } -SetPageUptodate (page); - }else { - rc =ecryptfs_read_lower_page_segment ( - page, index,0 ,PAGE_CACHE_SIZE , - mapping->host); -if (rc) { -printk (KERN_ERR "%s: Error reading " -"page; rc = [%d]\n" , - __func__, rc); -ClearPageUptodate (page); - goto out; - } -SetPageUptodate (page); - } }else { +BUG_ON (crypt_stat->flags &ECRYPTFS_VIEW_AS_ENCRYPTED );if (prev_page_end_size >=i_size_read (page->mapping->host)) {zero_user (page,0 ,PAGE_CACHE_SIZE );
Signature · 1 line
1.7.6.5
PATCH 3/3 eCryptfs: Remove unreached codes
In reply to a message not in the archiveThe code segment handles the ECRYPTFS_VIEW_AS_ENCRYPTED option in ecryptfs_write_begin(mmap.c) is unreached, since this option is enabled only when eCryptfs is mounted with RDONLY.
--- fs/ecryptfs/mmap.c | 29 +---------------------------- 1 files changed, 1 insertions(+), 28 deletions(-)
fs/ecryptfs/mmap.c +1 -28
@@ -320,35 +320,8 @@ static int ecryptfs_write_begin(struct file *file, goto out; }else SetPageUptodate (page); - }else if (crypt_stat->flags &ECRYPTFS_VIEW_AS_ENCRYPTED ) { -if (crypt_stat->flags &ECRYPTFS_METADATA_IN_XATTR ) { - rc =ecryptfs_copy_up_encrypted_with_header ( - page, crypt_stat); -if (rc) { -printk (KERN_ERR "%s: Error attempting " -"to copy the encrypted content " -"from the lower file whilst " -"inserting the metadata from " -"the xattr into the header; rc " -"= [%d]\n" , __func__, rc); -ClearPageUptodate (page); - goto out; - } -SetPageUptodate (page); - }else { - rc =ecryptfs_read_lower_page_segment ( - page, index,0 ,PAGE_CACHE_SIZE , - mapping->host); -if (rc) { -printk (KERN_ERR "%s: Error reading " -"page; rc = [%d]\n" , - __func__, rc); -ClearPageUptodate (page); - goto out; - } -SetPageUptodate (page); - } }else { +BUG_ON (crypt_stat->flags &ECRYPTFS_VIEW_AS_ENCRYPTED );if (prev_page_end_size >=i_size_read (page->mapping->host)) {zero_user (page,0 ,PAGE_CACHE_SIZE );
Signature · 1 line
1.7.6.5