From: Markus Elfring <Markus.Elfring@web.de>
To: Liao Yuanhong <liaoyuanhong@vivo.com>,
linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
Damien Le Moal <dlemoal@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] elevator: avoid redundant conditions
Date: Thu, 4 Sep 2025 08:05:54 +0200 [thread overview]
Message-ID: <a8d29094-2db3-495e-8a71-9d11992c4d9c@web.de> (raw)
In-Reply-To: <20250903121405.386483-1-liaoyuanhong@vivo.com>
…
> 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;
Regards,
Markus
next prev parent reply other threads:[~2025-09-04 6:07 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 [this message]
2025-09-04 6:05 ` Damien Le Moal
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=a8d29094-2db3-495e-8a71-9d11992c4d9c@web.de \
--to=markus.elfring@web.de \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--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