* [PATCH] ext2/ext3:useless code for return value
@ 2010-05-06 13:36 "潘卫平(Peter Pan)"
2010-05-07 16:23 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: "潘卫平(Peter Pan)" @ 2010-05-06 13:36 UTC (permalink / raw)
To: tj, Christoph Lameter, hch, akpm, adilger
Cc: linux-ext4, linux-kernel, kernel-janitors
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;
}
/*
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index a177122..bfa62e9 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -310,11 +310,7 @@ search_reserve_window(struct rb_root *root,
ext3_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 ext3_reserve_window_node, rsv_node);
- }
- return rsv;
+ return (rsv->rsv_start < goal) ? rsv : NULL;
}
/**
--
1.6.6
--
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext2/ext3:useless code for return value
2010-05-06 13:36 [PATCH] ext2/ext3:useless code for return value "潘卫平(Peter Pan)"
@ 2010-05-07 16:23 ` Jan Kara
2010-05-10 2:36 ` "潘卫平(Peter Pan)"
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2010-05-07 16:23 UTC (permalink / raw)
To: "潘卫平(Peter Pan)"
Cc: tj, Christoph Lameter, hch, akpm, adilger, linux-ext4,
linux-kernel, kernel-janitors
> 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
--
Jan Kara <jack@suse.cz>
SuSE CR Labs
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext2/ext3:useless code for return value
2010-05-07 16:23 ` Jan Kara
@ 2010-05-10 2:36 ` "潘卫平(Peter Pan)"
0 siblings, 0 replies; 3+ messages in thread
From: "潘卫平(Peter Pan)" @ 2010-05-10 2:36 UTC (permalink / raw)
To: Jan Kara
Cc: tj, Christoph Lameter, hch, akpm, adilger, linux-ext4,
linux-kernel, kernel-janitors
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-10 2:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-06 13:36 [PATCH] ext2/ext3:useless code for return value "潘卫平(Peter Pan)"
2010-05-07 16:23 ` Jan Kara
2010-05-10 2:36 ` "潘卫平(Peter Pan)"
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).