[dm-devel] [PATCH 1/4] libmultipath: enable linear ordering of bus/proto tuple

Martin Wilck mwilck at suse.com
Mon Feb 21 21:26:51 UTC 2022


On Thu, 2022-02-17 at 20:55 +0100, mwilck at suse.com wrote:
> From: Martin Wilck <mwilck at suse.com>
> 
> We categorized protocols by bus/proto_id, while we only differentiate
> protocol IDs for SCSI. Allow transforming this into a linear sequence
> of bus/protocol IDs by having non-SCSI first, and follwing up with
> the different SCSI protocols.
> 
> Signed-off-by: Martin Wilck <mwilck at suse.com>
> ---
>  libmultipath/structs.c | 10 ++++++++++
>  libmultipath/structs.h | 13 +++++++++++--
>  2 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/libmultipath/structs.c b/libmultipath/structs.c
> index 17f4baf..5849bf1 100644
> --- a/libmultipath/structs.c
> +++ b/libmultipath/structs.c
> @@ -753,3 +753,13 @@ out:
>  
>         return 0;
>  }
> +
> +unsigned int bus_protocol_id(const struct path *pp) {
> +       if (!pp || pp->bus < 0 || pp->bus > SYSFS_BUS_SCSI)
> +               return SYSFS_BUS_UNDEF;
> +       if (pp->bus != SYSFS_BUS_SCSI)
> +               return pp->bus;
> +       if (pp->sg_id.proto_id < 0 || pp->sg_id.proto_id

It turns out that ^^^^^^^^^^^^^^^^^^ this comparison causes
an error with clang 3.5, and possibly other compilers, because they
use an unsigned int type for sg_id.proto_id.

Because some compilers will use "int", instead of dropping the test,
I'll just add a cast to (int).

Regards
Martin





More information about the dm-devel mailing list