public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Markus Elfring <Markus.Elfring@web.de>,
	Liao Yuanhong <liaoyuanhong@vivo.com>,
	linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] elevator: avoid redundant conditions
Date: Thu, 4 Sep 2025 15:05:37 +0900	[thread overview]
Message-ID: <5561e689-03be-4cb2-9cd6-788accfd520a@kernel.org> (raw)
In-Reply-To: <a8d29094-2db3-495e-8a71-9d11992c4d9c@web.de>

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

      reply	other threads:[~2025-09-04  6:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03 12:14 [PATCH] elevator: avoid redundant conditions Liao Yuanhong
2025-09-04  2:33 ` Damien Le Moal
2025-09-04  6:05 ` Markus Elfring
2025-09-04  6:05   ` Damien Le Moal [this message]

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=5561e689-03be-4cb2-9cd6-788accfd520a@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=Markus.Elfring@web.de \
    --cc=axboe@kernel.dk \
    --cc=liaoyuanhong@vivo.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox