public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Namjae Jeon <linkinjeon@gmail.com>
Cc: tytso@mit.edu, linux-kernel@vger.kernel.org,
	linux-ext4@vger.kernel.org,
	Amit Sahrawat <amit.sahrawat83@gmail.com>
Subject: Re: [PATCH] ext4: remove unneeded variable.
Date: Sun, 20 Nov 2011 01:41:26 +0530	[thread overview]
Message-ID: <4EC80D6E.3090404@linux.vnet.ibm.com> (raw)
In-Reply-To: <1321023744-16249-1-git-send-email-linkinjeon@gmail.com>

On 11/11/2011 08:32 PM, Namjae Jeon wrote:
> ret2 is not needed in ext4_flush_completed_IO().
> 

Not needed? I went through the code briefly, and I don't agree.

> Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
> Signed-off-by: Amit Sahrawat <amit.sahrawat83@gmail.com>
> ---
>  fs/ext4/fsync.c |    5 +----
>  1 files changed, 1 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
> index 00a2cb7..40397ac 100644
> --- a/fs/ext4/fsync.c
> +++ b/fs/ext4/fsync.c
> @@ -81,7 +81,6 @@ int ext4_flush_completed_IO(struct inode *inode)
>  	struct ext4_inode_info *ei = EXT4_I(inode);
>  	unsigned long flags;
>  	int ret = 0;
> -	int ret2 = 0;
> 
>  	dump_completed_IO(inode);
>  	spin_lock_irqsave(&ei->i_completed_io_lock, flags);
> @@ -105,12 +104,10 @@ int ext4_flush_completed_IO(struct inode *inode)
>  		 */
>  		spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);
>  		ret = ext4_end_io_nolock(io);
> -		if (ret < 0)
> -			ret2 = ret;
>  		spin_lock_irqsave(&ei->i_completed_io_lock, flags);
>  	}
>  	spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);
> -	return (ret2 < 0) ? ret2 : 0;
> +	return (ret < 0) ? ret : 0;
>  }

Please note that there is a while loop involved here. Which means, that ret2
is used to store the last negative value of ret. And due to the loop, ret can
be over-written in the next loop iteration, which we can afford, because we
have already stored what we need to save, in ret2. And this ret2 value is used
to return appropriate value to the caller. 

Thanks,
Srivatsa S. Bhat


  parent reply	other threads:[~2011-11-19 20:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-11 15:02 [PATCH] ext4: remove unneeded variable Namjae Jeon
2011-11-17  9:45 ` Amit Sahrawat
2011-11-19 20:11 ` Srivatsa S. Bhat [this message]
2011-11-19 21:09   ` Srivatsa S. Bhat
2011-11-19 21:53     ` NamJae Jeon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EC80D6E.3090404@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=amit.sahrawat83@gmail.com \
    --cc=linkinjeon@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox