2021-09-30 07:18:54

by Li RongQing

[permalink] [raw]
Subject: [PATCH] rbtree: Remove unneeded check condition in rb_find_first

the variable c is int type, so change the following condition

if (c <= 0) {

}
else if (c > 0) {

}
as:
if (c <= 0) {

}
else {

}

Spotted-by: Michel Lespinasse <<[email protected]>>
Signed-off-by: Li RongQing <[email protected]>
---
include/linux/rbtree.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 235047d..d5ac8f7 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -294,7 +294,7 @@ static inline void rb_replace_node_cached(struct rb_node *victim,
if (!c)
match = node;
node = node->rb_left;
- } else if (c > 0) {
+ } else {
node = node->rb_right;
}
}
--
1.7.1


2021-09-30 23:09:07

by Michel Lespinasse

[permalink] [raw]
Subject: Re: [PATCH] rbtree: Remove unneeded check condition in rb_find_first

On Thu, Sep 30, 2021 at 03:16:36PM +0800, Li RongQing wrote:
> the variable c is int type, so change the following condition
>
> if (c <= 0) {
>
> }
> else if (c > 0) {
>
> }
> as:
> if (c <= 0) {
>
> }
> else {
>
> }
>
> Spotted-by: Michel Lespinasse <<[email protected]>>
> Signed-off-by: Li RongQing <[email protected]>
> ---
> include/linux/rbtree.h | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
> index 235047d..d5ac8f7 100644
> --- a/include/linux/rbtree.h
> +++ b/include/linux/rbtree.h
> @@ -294,7 +294,7 @@ static inline void rb_replace_node_cached(struct rb_node *victim,
> if (!c)
> match = node;
> node = node->rb_left;
> - } else if (c > 0) {
> + } else {
> node = node->rb_right;
> }
> }

Looks good to me, thanks for the fix.

Reviewed-by: Michel Lespinasse <[email protected]>

--
Michel "walken" Lespinasse

2021-10-22 04:21:55

by Li RongQing

[permalink] [raw]
Subject: 答复: [PATCH] rbtree: Remove unneeded check c ondition in rb_find_first

Ping

-Li

> On Thu, Sep 30, 2021 at 03:16:36PM +0800, Li RongQing wrote:
> > the variable c is int type, so change the following condition
> >
> > if (c <= 0) {
> >
> > }
> > else if (c > 0) {
> >
> > }
> > as:
> > if (c <= 0) {
> >
> > }
> > else {
> >
> > }
> >
> > Spotted-by: Michel Lespinasse <<[email protected]>>
> > Signed-off-by: Li RongQing <[email protected]>
> > ---
> > include/linux/rbtree.h | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h index
> > 235047d..d5ac8f7 100644
> > --- a/include/linux/rbtree.h
> > +++ b/include/linux/rbtree.h
> > @@ -294,7 +294,7 @@ static inline void rb_replace_node_cached(struct
> rb_node *victim,
> > if (!c)
> > match = node;
> > node = node->rb_left;
> > - } else if (c > 0) {
> > + } else {
> > node = node->rb_right;
> > }
> > }
>
> Looks good to me, thanks for the fix.
>
> Reviewed-by: Michel Lespinasse <[email protected]>
>
> --
> Michel "walken" Lespinasse