mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dm btree: Remove redundant index condition
@ 2026-11-06  7:57 Donut Oreo Computer I
  2026-11-16 20:00 ` Mikulas Patocka
  0 siblings, 1 reply; 2+ messages in thread
From: Donut Oreo Computer I @ 2026-11-06  7:57 UTC (permalink / raw)
  To: dm-devel
  Cc: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
	Benjamin Marzinski, linux-kernel

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

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dm btree: Remove redundant index condition
  2026-11-06  7:57 [PATCH] dm btree: Remove redundant index condition Donut Oreo Computer I
@ 2026-11-16 20:00 ` Mikulas Patocka
  0 siblings, 0 replies; 2+ messages in thread
From: Mikulas Patocka @ 2026-11-16 20:00 UTC (permalink / raw)
  To: Donut Oreo Computer I
  Cc: dm-devel, Alasdair Kergon, Mike Snitzer, Benjamin Marzinski,
	linux-kernel



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
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-16 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06  7:57 [PATCH] dm btree: Remove redundant index condition Donut Oreo Computer I
2026-11-16 20:00 ` Mikulas Patocka

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®