[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5561e689-03be-4cb2-9cd6-788accfd520a@kernel.org>
Date: Thu, 4 Sep 2025 15:05:37 +0900
From: Damien Le Moal <dlemoal@...nel.org>
To: Markus Elfring <Markus.Elfring@....de>,
Liao Yuanhong <liaoyuanhong@...o.com>, linux-block@...r.kernel.org,
Jens Axboe <axboe@...nel.dk>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] elevator: avoid redundant conditions
On 9/4/25 3:05 PM, Markus Elfring wrote:
> …
>> it avoids writing out a condition that is unnecessary. Let's drop such
>
> Thus?
>
>
>> unnecessary conditions.
>
> an unnecessary condition?
>
>
> Would a summary phrase like “Avoid redundant condition in elv_rb_add()”
> be nicer?
>
>
> …
>> +++ b/block/elevator.c
>> @@ -240,7 +240,7 @@ void elv_rb_add(struct rb_root *root, struct request *rq)
>>
>> if (blk_rq_pos(rq) < blk_rq_pos(__rq))
>> p = &(*p)->rb_left;
>> - else if (blk_rq_pos(rq) >= blk_rq_pos(__rq))
>> + else
>> p = &(*p)->rb_right;
>
>
> Would you dare to apply a conditional expression here?
>
> p = (blk_rq_pos(rq) < blk_rq_pos(__rq)) ? &(*p)->rb_left : &(*p)->rb_right;
This is far less readable.
>
>
> Regards,
> Markus
--
Damien Le Moal
Western Digital Research
Powered by blists - more mailing lists