linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: ecryptfs: crypto: Change return type of ecryptfs_process_flags
@ 2019-07-02 17:47 Hariprasad Kelam
  2019-07-02 19:25 ` Tyler Hicks
  0 siblings, 1 reply; 2+ messages in thread
From: Hariprasad Kelam @ 2019-07-02 17:47 UTC (permalink / raw)
  To: Tyler Hicks, ecryptfs, linux-kernel

Change return type of ecryptfs_process_flags from int to void. As it
never fails.

fixes below issue reported by coccicheck

s/ecryptfs/crypto.c:870:5-7: Unneeded variable: "rc". Return "0" on line
883

Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
---
 fs/ecryptfs/crypto.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 509a767..55a633e 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -864,10 +864,9 @@ static struct ecryptfs_flag_map_elem ecryptfs_flag_map[] = {
  *
  * Returns zero on success; non-zero if the flag set is invalid
  */
-static int ecryptfs_process_flags(struct ecryptfs_crypt_stat *crypt_stat,
+static void ecryptfs_process_flags(struct ecryptfs_crypt_stat *crypt_stat,
 				  char *page_virt, int *bytes_read)
 {
-	int rc = 0;
 	int i;
 	u32 flags;
 
@@ -880,7 +879,6 @@ static int ecryptfs_process_flags(struct ecryptfs_crypt_stat *crypt_stat,
 	/* Version is in top 8 bits of the 32-bit flag vector */
 	crypt_stat->file_version = ((flags >> 24) & 0xFF);
 	(*bytes_read) = 4;
-	return rc;
 }
 
 /**
@@ -1306,12 +1304,9 @@ static int ecryptfs_read_headers_virt(char *page_virt,
 	if (!(crypt_stat->flags & ECRYPTFS_I_SIZE_INITIALIZED))
 		ecryptfs_i_size_init(page_virt, d_inode(ecryptfs_dentry));
 	offset += MAGIC_ECRYPTFS_MARKER_SIZE_BYTES;
-	rc = ecryptfs_process_flags(crypt_stat, (page_virt + offset),
+	ecryptfs_process_flags(crypt_stat, (page_virt + offset),
 				    &bytes_read);
-	if (rc) {
-		ecryptfs_printk(KERN_WARNING, "Error processing flags\n");
-		goto out;
-	}
+
 	if (crypt_stat->file_version > ECRYPTFS_SUPPORTED_FILE_VERSION) {
 		ecryptfs_printk(KERN_WARNING, "File version is [%d]; only "
 				"file version [%d] is supported by this "
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs: ecryptfs: crypto: Change return type of ecryptfs_process_flags
  2019-07-02 17:47 [PATCH] fs: ecryptfs: crypto: Change return type of ecryptfs_process_flags Hariprasad Kelam
@ 2019-07-02 19:25 ` Tyler Hicks
  0 siblings, 0 replies; 2+ messages in thread
From: Tyler Hicks @ 2019-07-02 19:25 UTC (permalink / raw)
  To: Hariprasad Kelam; +Cc: ecryptfs, linux-kernel

On 2019-07-02 23:17:24, Hariprasad Kelam wrote:
> Change return type of ecryptfs_process_flags from int to void. As it
> never fails.
> 
> fixes below issue reported by coccicheck
> 
> s/ecryptfs/crypto.c:870:5-7: Unneeded variable: "rc". Return "0" on line
> 883
> 
> Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
> ---

Thanks for the cleanup! I made some minor tweaks, as noted below, and
pushed it to the eCryptfs next branch.

>  fs/ecryptfs/crypto.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
> index 509a767..55a633e 100644
> --- a/fs/ecryptfs/crypto.c
> +++ b/fs/ecryptfs/crypto.c
> @@ -864,10 +864,9 @@ static struct ecryptfs_flag_map_elem ecryptfs_flag_map[] = {
>   *
>   * Returns zero on success; non-zero if the flag set is invalid

I deleted this line from the function documentation.

>   */
> -static int ecryptfs_process_flags(struct ecryptfs_crypt_stat *crypt_stat,
> +static void ecryptfs_process_flags(struct ecryptfs_crypt_stat *crypt_stat,
>  				  char *page_virt, int *bytes_read)
>  {
> -	int rc = 0;
>  	int i;
>  	u32 flags;
>  
> @@ -880,7 +879,6 @@ static int ecryptfs_process_flags(struct ecryptfs_crypt_stat *crypt_stat,
>  	/* Version is in top 8 bits of the 32-bit flag vector */
>  	crypt_stat->file_version = ((flags >> 24) & 0xFF);
>  	(*bytes_read) = 4;
> -	return rc;
>  }
>  
>  /**
> @@ -1306,12 +1304,9 @@ static int ecryptfs_read_headers_virt(char *page_virt,
>  	if (!(crypt_stat->flags & ECRYPTFS_I_SIZE_INITIALIZED))
>  		ecryptfs_i_size_init(page_virt, d_inode(ecryptfs_dentry));
>  	offset += MAGIC_ECRYPTFS_MARKER_SIZE_BYTES;
> -	rc = ecryptfs_process_flags(crypt_stat, (page_virt + offset),
> +	ecryptfs_process_flags(crypt_stat, (page_virt + offset),
>  				    &bytes_read);

The line was short enough to move the last argument up to the same line
so I went ahead and did that.

Thanks again!

Tyler

> -	if (rc) {
> -		ecryptfs_printk(KERN_WARNING, "Error processing flags\n");
> -		goto out;
> -	}
> +
>  	if (crypt_stat->file_version > ECRYPTFS_SUPPORTED_FILE_VERSION) {
>  		ecryptfs_printk(KERN_WARNING, "File version is [%d]; only "
>  				"file version [%d] is supported by this "
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-02 19:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02 17:47 [PATCH] fs: ecryptfs: crypto: Change return type of ecryptfs_process_flags Hariprasad Kelam
2019-07-02 19:25 ` Tyler Hicks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).