* [PATCH] Btrfs: Remove useless condition
@ 2010-09-12 11:02 Jaswinder Singh Rajput
2010-09-12 12:29 ` Johannes Weiner
0 siblings, 1 reply; 4+ messages in thread
From: Jaswinder Singh Rajput @ 2010-09-12 11:02 UTC (permalink / raw)
To: Chris Mason, linux-btrfs, LKML
if (ret) is useless as it will be never NULL as in previous statement
we are setting ret = prev for !ret
Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Cc: Chris Mason <chris.mason@oracle.com>
---
fs/btrfs/ordered-data.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index e56c72b..7b04008 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -154,8 +154,7 @@ static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree,
ret = __tree_search(root, file_offset, &prev);
if (!ret)
ret = prev;
- if (ret)
- tree->last = ret;
+ tree->last = ret;
return ret;
}
--
1.7.2.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: Remove useless condition
2010-09-12 11:02 [PATCH] Btrfs: Remove useless condition Jaswinder Singh Rajput
@ 2010-09-12 12:29 ` Johannes Weiner
2010-09-12 13:56 ` Jaswinder Singh Rajput
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Weiner @ 2010-09-12 12:29 UTC (permalink / raw)
To: Jaswinder Singh Rajput; +Cc: Chris Mason, linux-btrfs, LKML
On Sun, Sep 12, 2010 at 04:32:20PM +0530, Jaswinder Singh Rajput wrote:
>
> if (ret) is useless as it will be never NULL as in previous statement
> we are setting ret = prev for !ret
If there is no match and no extent below the given file offset, `prev'
will be NULL as well, no?
So the check is not useless, it prevents throwing out a cached success
in case of a lookup failure.
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
> Cc: Chris Mason <chris.mason@oracle.com>
> ---
> fs/btrfs/ordered-data.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
> index e56c72b..7b04008 100644
> --- a/fs/btrfs/ordered-data.c
> +++ b/fs/btrfs/ordered-data.c
> @@ -154,8 +154,7 @@ static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree,
> ret = __tree_search(root, file_offset, &prev);
> if (!ret)
> ret = prev;
> - if (ret)
> - tree->last = ret;
> + tree->last = ret;
> return ret;
> }
>
> --
> 1.7.2.2
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: Remove useless condition
2010-09-12 12:29 ` Johannes Weiner
@ 2010-09-12 13:56 ` Jaswinder Singh Rajput
2010-09-12 17:28 ` Mike Fedyk
0 siblings, 1 reply; 4+ messages in thread
From: Jaswinder Singh Rajput @ 2010-09-12 13:56 UTC (permalink / raw)
To: Johannes Weiner; +Cc: Chris Mason, linux-btrfs, LKML
Hello,
On Sun, Sep 12, 2010 at 5:59 PM, Johannes Weiner <hannes@cmpxchg.org> wrote:
> On Sun, Sep 12, 2010 at 04:32:20PM +0530, Jaswinder Singh Rajput wrote:
>>
>> if (ret) is useless as it will be never NULL as in previous statement
>> we are setting ret = prev for !ret
>
> If there is no match and no extent below the given file offset, `prev'
> will be NULL as well, no?
>
> So the check is not useless, it prevents throwing out a cached success
> in case of a lookup failure.
>
Got it !!
Thanks,
--
Jaswinder Singh.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: Remove useless condition
2010-09-12 13:56 ` Jaswinder Singh Rajput
@ 2010-09-12 17:28 ` Mike Fedyk
0 siblings, 0 replies; 4+ messages in thread
From: Mike Fedyk @ 2010-09-12 17:28 UTC (permalink / raw)
To: Jaswinder Singh Rajput; +Cc: Johannes Weiner, Chris Mason, linux-btrfs, LKML
On Sun, Sep 12, 2010 at 6:56 AM, Jaswinder Singh Rajput
<jaswinderlinux@gmail.com> wrote:
> Hello,
>
> On Sun, Sep 12, 2010 at 5:59 PM, Johannes Weiner <hannes@cmpxchg.org> wrote:
>> On Sun, Sep 12, 2010 at 04:32:20PM +0530, Jaswinder Singh Rajput wrote:
>>>
>>> if (ret) is useless as it will be never NULL as in previous statement
>>> we are setting ret = prev for !ret
>>
>> If there is no match and no extent below the given file offset, `prev'
>> will be NULL as well, no?
>>
>> So the check is not useless, it prevents throwing out a cached success
>> in case of a lookup failure.
>>
>
> Got it !!
>
Wouldn't it be clearer and easier to read if prev was checked directly
instead of checking ret after it becomes the same as prev?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-09-12 17:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-12 11:02 [PATCH] Btrfs: Remove useless condition Jaswinder Singh Rajput
2010-09-12 12:29 ` Johannes Weiner
2010-09-12 13:56 ` Jaswinder Singh Rajput
2010-09-12 17:28 ` Mike Fedyk
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).