mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Donut Oreo Computer I <donut.oreo.computer@gmail.com>
Cc: dm-devel@lists.linux.dev, Alasdair Kergon <agk@redhat.com>,
	 Mike Snitzer <snitzer@kernel.org>,
	 Benjamin Marzinski <bmarzins@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dm btree: Remove redundant index condition
Date: Mon, 16 Nov 2026 21:00:34 +0100 (CET)	[thread overview]
Message-ID: <f9266fcb-d030-dd16-e16f-0569b93bf4b6@redhat.com> (raw)
In-Reply-To: <CALKjhPewyFB0=2tfyNVuDPosTAisDD2YcejTpX+0iiKRXdsGaw@mail.gmail.com>



On Fri, 6 Nov 2026, Donut Oreo Computer I wrote:

> The index is unsigned, so checking whether i is non-negative is
> unnecessary.

Really?

In the caller, there is

"unsigned int level, index = -1, last_level = info->levels - 1;"

In btree_insert_raw, there is "int r, i = *index, top = 1;"

If you cast -1 to unsigned int and then cast it back to int, you get -1.

So, it doesn't seem like an obvious dead code to me.

Mikulas

> Signed-off-by: Donut Oreo Computer <donut.oreo.computer@gmail.com>
> ---
>  drivers/md/persistent-data/dm-btree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/persistent-data/dm-btree.c
> b/drivers/md/persistent-data/dm-btree.c
> index dd02eee4a23c..b7ac2f6d1d71 100644
> --- a/drivers/md/persistent-data/dm-btree.c
> +++ b/drivers/md/persistent-data/dm-btree.c
> @@ -1108,7 +1108,7 @@ static int btree_insert_raw(struct shadow_spine
> *s, dm_block_t root,
>                  * see a way to do this automatically as part of the spine
>                  * op.
>                  */
> -               if (shadow_has_parent(s) && i >= 0) { /* FIXME: second
> clause unness. */
> +               if (shadow_has_parent(s)) {
>                         __le64 location =
> cpu_to_le64(dm_block_location(shadow_current(s)));
> 
>                         __dm_bless_for_disk(&location);
> --
> 2.56.0
> 


      reply	other threads:[~2026-11-16 20:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06  7:57 Donut Oreo Computer I
2026-11-16 20:00 ` Mikulas Patocka [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=f9266fcb-d030-dd16-e16f-0569b93bf4b6@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=donut.oreo.computer@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=snitzer@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

all inboxes | Powered by JetHome®