All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Alex Kalenyuk <akalenyu@redhat.com>
Cc: dm-devel@lists.linux.dev, mwilck@suse.com
Subject: Re: [PATCH] Take undef enum into account for correct array index comparison
Date: Mon, 18 Aug 2025 13:19:34 -0400	[thread overview]
Message-ID: <aKNgpm9XllLUyEiJ@redhat.com> (raw)
In-Reply-To: <20250817194923.307911-1-akalenyu@redhat.com>

On Sun, Aug 17, 2025 at 10:49:23PM +0300, Alex Kalenyuk wrote:
> Previously this would compare to the wrong index
> since the enum has an additional UNDEF entry

Are you actually seeing multipath getting misconfigured here, because
the code doesn't look wrong to me.  We didn't and the "undef" elements
because we don't want to accept "undef" as a valid value from the config
file.

This code is admittedly a little confusing.  We aren't looping from 0 to
the last value, we are looping from FIND_MULTIPATHS_OFF or FLUSH_NEVER
(which have the value of 1). The way the loop works, we won't even check
the config text against the array elements you added. We intentionally
only set elements in those arrays at the values we want to start
checking at: FIND_MULTIPATHS_OFF and FLUSH_NEVER. As long as the text in
the optvals array is correct for the value we are using as its index, if
we match the config text with the optvals text, 'i' must be equal to the
value we want (since the value we want is array index of the matching
text).

If you are seeing a configuration issue, we do want to hear about it.
I'm not saying there isn't a bug, but unless I'm missing something, I
don't think that this is it. Also multipath's configuration priority
isn't always super intuitive, so sometimes it is working as designed,
but not you might intuitively expect.

-Ben

> 
> Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
> ---
>  libmultipath/dict.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libmultipath/dict.c b/libmultipath/dict.c
> index a06a6138..2e820b2e 100644
> --- a/libmultipath/dict.c
> +++ b/libmultipath/dict.c
> @@ -550,6 +550,7 @@ static int snprint_def_partition_delim(struct config *conf, struct strbuf *buff,
>  }
>  
>  static const char * const find_multipaths_optvals[] = {
> +	[FIND_MULTIPATHS_UNDEF] = "undef",
>  	[FIND_MULTIPATHS_OFF] = "off",
>  	[FIND_MULTIPATHS_ON] = "on",
>  	[FIND_MULTIPATHS_STRICT] = "strict",
> @@ -793,6 +794,7 @@ declare_def_snprint(allow_usb_devices, print_yes_no)
>  
>  
>  static const char * const flush_on_last_del_optvals[] = {
> +	[FLUSH_UNDEF] = "undef",
>  	[FLUSH_NEVER] = "never",
>  	[FLUSH_ALWAYS] = "always",
>  	[FLUSH_UNUSED] = "unused",
> -- 
> 2.50.1


  reply	other threads:[~2025-08-18 17:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-17 19:49 [PATCH] Take undef enum into account for correct array index comparison Alex Kalenyuk
2025-08-18 17:19 ` Benjamin Marzinski [this message]
2025-08-19  7:14   ` Alex Kalenyuk

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=aKNgpm9XllLUyEiJ@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=akalenyu@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=mwilck@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.