>>> Sasha Levin <sas...@kernel.org> schrieb am 16.11.2019 um 16:38 in Nachricht
<20191116154113.7417-54-sas...@kernel.org>:
> From: Nathan Chancellor <natechancel...@gmail.com>
> 
> [ Upstream commit 20054597f169090109fc3f0dfa1a48583f4178a4 ]
> 
> Clang warns when one enumerated type is implicitly converted to another.

IMHO even an explicit cast doesn't make it better: Either it's the same enum, 
or it's a different one.
The only clean solution IMHO would be a converter function like

enum out convert_enum_in(enum in i)
{
  switch (i)
  {
     case enum_in_1: return enum_out_1; break;
     case enum_in_2: return enum_out_2; break;
     ...
     default: bad_value(i);
  }
}

Maybe a clever compiler can make this (almost) a no-op, but it should be clear 
that assigning different enums to each other is a bad idea.

> 
> drivers/scsi/iscsi_tcp.c:803:15: warning: implicit conversion from
> enumeration type 'enum iscsi_host_param' to different enumeration type
> 'enum iscsi_param' [-Wenum-conversion]
>                                                  &addr, param, buf);
>                                                         ^~~~~
> 1 warning generated.
> 
> iscsi_conn_get_addr_param handles ISCSI_HOST_PARAM_IPADDRESS just fine
> so add an explicit cast to iscsi_param to make it clear to Clang that
> this is expected behavior.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/153 
> Signed-off-by: Nathan Chancellor <natechancel...@gmail.com>
> Reviewed-by: Nick Desaulniers <ndesaulni...@google.com>
> Signed-off-by: Martin K. Petersen <martin.peter...@oracle.com>
> Signed-off-by: Sasha Levin <sas...@kernel.org>
> ---
>  drivers/scsi/iscsi_tcp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
> index b025a0b743417..23354f206533b 100644
> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -800,7 +800,8 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host 
> *shost,
>                       return rc;
>  
>               return iscsi_conn_get_addr_param((struct sockaddr_storage *)
> -                                              &addr, param, buf);
> +                                              &addr,
> +                                              (enum iscsi_param)param, buf);
>       default:
>               return iscsi_host_get_param(shost, param, buf);
>       }
> -- 
> 2.20.1
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "open-iscsi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to open-iscsi+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/open-iscsi/20191116154113.7417-54-sashal%40 
> kernel.org.




-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/5DD2642F020000A1000353FC%40gwsmtp.uni-regensburg.de.

Reply via email to