All of lore.kernel.org
 help / color / mirror / Atom feed
To: Jan Kara <jack@suse.cz>
Cc: tj@kernel.org, Christoph Lameter <cl@linux-foundation.org>,
	hch@lst.de, akpm@linux-foundation.org, adilger@sun.com,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ext2/ext3:useless code for return value
Date: Mon, 10 May 2010 02:36:57 +0000	[thread overview]
Message-ID: <4BE77149.8050307@redflag-linux.com> (raw)
In-Reply-To: <20100507162348.GD3265@atrey.karlin.mff.cuni.cz>

On 05/08/2010 12:23 AM, Jan Kara wrote:
>> When rsv is the right hand side of goal, we should return NULL,
>> because now rsv's prev is NULL, or we return rsv.
>>
>> Signed-off-by: Peter Pan(潘卫平)<wppan@redflag-linux.com>
>>
>> ---
>>   fs/ext2/balloc.c |    6 +-----
>>   fs/ext3/balloc.c |    6 +-----
>>   2 files changed, 2 insertions(+), 10 deletions(-)
>>
>> diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
>> index 3cf038c..023990f 100644
>> --- a/fs/ext2/balloc.c
>> +++ b/fs/ext2/balloc.c
>> @@ -323,11 +323,7 @@ search_reserve_window(struct rb_root *root,
>> ext2_fsblk_t goal)
>>   	 * side of the interval containing the goal.  If it's the RHS,
>>   	 * we need to back up one.
>>   	 */
>> -	if (rsv->rsv_start>  goal) {
>> -		n = rb_prev(&rsv->rsv_node);
>> -		rsv = rb_entry(n, struct ext2_reserve_window_node, rsv_node);
>> -	}
>> -	return rsv;
>> +    return (rsv->rsv_start<  goal) ? rsv : NULL;
>    Hmm, I'm not sure I understand your reasoning. Suppose we have an RB-tree
> with two intervals 0-10, 20-30. Interval 0-10 is in the root. Now we search
> for goal 15. In the root we go to right because 10<15, in the next node we go
> to left because 15<  20. Then the loop terminates. Now your code would return
> NULL but previous code would return rb_prev of interval 20-30 which is 0-10.
> And that is what we want as far as I understand what we expect from the
> function...
>
> 								Honza
You got the point!
Many thanks.

Regards
-- 
Peter Pan
Red Flag Software Co.,Ltd

WARNING: multiple messages have this Message-ID (diff)
From: "\"潘卫平(Peter Pan)\"" <wppan@redflag-linux.com>
To: Jan Kara <jack@suse.cz>
Cc: tj@kernel.org, Christoph Lameter <cl@linux-foundation.org>,
	hch@lst.de, akpm@linux-foundation.org, adilger@sun.com,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ext2/ext3:useless code for return value
Date: Mon, 10 May 2010 10:36:57 +0800	[thread overview]
Message-ID: <4BE77149.8050307@redflag-linux.com> (raw)
In-Reply-To: <20100507162348.GD3265@atrey.karlin.mff.cuni.cz>

On 05/08/2010 12:23 AM, Jan Kara wrote:
>> When rsv is the right hand side of goal, we should return NULL,
>> because now rsv's prev is NULL, or we return rsv.
>>
>> Signed-off-by: Peter Pan(潘卫平)<wppan@redflag-linux.com>
>>
>> ---
>>   fs/ext2/balloc.c |    6 +-----
>>   fs/ext3/balloc.c |    6 +-----
>>   2 files changed, 2 insertions(+), 10 deletions(-)
>>
>> diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
>> index 3cf038c..023990f 100644
>> --- a/fs/ext2/balloc.c
>> +++ b/fs/ext2/balloc.c
>> @@ -323,11 +323,7 @@ search_reserve_window(struct rb_root *root,
>> ext2_fsblk_t goal)
>>   	 * side of the interval containing the goal.  If it's the RHS,
>>   	 * we need to back up one.
>>   	 */
>> -	if (rsv->rsv_start>  goal) {
>> -		n = rb_prev(&rsv->rsv_node);
>> -		rsv = rb_entry(n, struct ext2_reserve_window_node, rsv_node);
>> -	}
>> -	return rsv;
>> +    return (rsv->rsv_start<  goal) ? rsv : NULL;
>    Hmm, I'm not sure I understand your reasoning. Suppose we have an RB-tree
> with two intervals 0-10, 20-30. Interval 0-10 is in the root. Now we search
> for goal 15. In the root we go to right because 10<15, in the next node we go
> to left because 15<  20. Then the loop terminates. Now your code would return
> NULL but previous code would return rb_prev of interval 20-30 which is 0-10.
> And that is what we want as far as I understand what we expect from the
> function...
>
> 								Honza
You got the point!
Many thanks.

Regards
-- 
Peter Pan
Red Flag Software Co.,Ltd
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: "\"潘卫平(Peter Pan)\"" <wppan@redflag-linux.com>
To: Jan Kara <jack@suse.cz>
Cc: tj@kernel.org, Christoph Lameter <cl@linux-foundation.org>,
	hch@lst.de, akpm@linux-foundation.org, adilger@sun.com,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ext2/ext3:useless code for return value
Date: Mon, 10 May 2010 10:36:57 +0800	[thread overview]
Message-ID: <4BE77149.8050307@redflag-linux.com> (raw)
In-Reply-To: <20100507162348.GD3265@atrey.karlin.mff.cuni.cz>

On 05/08/2010 12:23 AM, Jan Kara wrote:
>> When rsv is the right hand side of goal, we should return NULL,
>> because now rsv's prev is NULL, or we return rsv.
>>
>> Signed-off-by: Peter Pan(潘卫平)<wppan@redflag-linux.com>
>>
>> ---
>>   fs/ext2/balloc.c |    6 +-----
>>   fs/ext3/balloc.c |    6 +-----
>>   2 files changed, 2 insertions(+), 10 deletions(-)
>>
>> diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
>> index 3cf038c..023990f 100644
>> --- a/fs/ext2/balloc.c
>> +++ b/fs/ext2/balloc.c
>> @@ -323,11 +323,7 @@ search_reserve_window(struct rb_root *root,
>> ext2_fsblk_t goal)
>>   	 * side of the interval containing the goal.  If it's the RHS,
>>   	 * we need to back up one.
>>   	 */
>> -	if (rsv->rsv_start>  goal) {
>> -		n = rb_prev(&rsv->rsv_node);
>> -		rsv = rb_entry(n, struct ext2_reserve_window_node, rsv_node);
>> -	}
>> -	return rsv;
>> +    return (rsv->rsv_start<  goal) ? rsv : NULL;
>    Hmm, I'm not sure I understand your reasoning. Suppose we have an RB-tree
> with two intervals 0-10, 20-30. Interval 0-10 is in the root. Now we search
> for goal 15. In the root we go to right because 10<15, in the next node we go
> to left because 15<  20. Then the loop terminates. Now your code would return
> NULL but previous code would return rb_prev of interval 20-30 which is 0-10.
> And that is what we want as far as I understand what we expect from the
> function...
>
> 								Honza
You got the point!
Many thanks.

Regards
-- 
Peter Pan
Red Flag Software Co.,Ltd

  reply	other threads:[~2010-05-10  2:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-06 13:36 [PATCH] ext2/ext3:useless code for return value "潘卫平(Peter Pan)"
2010-05-06 13:36 ` "潘卫平(Peter Pan)"
2010-05-07 16:23 ` Jan Kara
2010-05-07 16:23   ` Jan Kara
2010-05-10  2:36   `  [this message]
2010-05-10  2:36     ` "潘卫平(Peter Pan)"
2010-05-10  2:36     ` "潘卫平(Peter Pan)"

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=4BE77149.8050307@redflag-linux.com \
    --to=jack@suse.cz \
    --cc=adilger@sun.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.