Skip to contentSkip to conversation

scsi: iscsi_tcp: Explicitly cast param in iscsi_sw_tcp_host_get_param

PATCH In review Nathan Chancellor 2 participants 2 messages Oct 4, 2018 – Oct 5, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: iscsi_tcp: Explicitly cast param in iscsi_sw_tcp_host_get_param

Clang warns when one enumerated type is implicitly converted to another.

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.

---
 drivers/scsi/iscsi_tcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/iscsi_tcp.c +2 -1
index b025a0b74341..23354f206533 100644
@@ -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);
 	}
Signature · 1 line
2.19.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Nathan Chancellor

Clang warns when one enumerated type is implicitly converted to another.

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.

---
 drivers/scsi/iscsi_tcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/iscsi_tcp.c +0 -0
index b025a0b74341..23354f206533 100644

drivers/scsi/iscsi_tcp.c static int iscsi_sw_tcp_host_get_param(struct Scsi_Host *shost, · line 804

Quoted 6 lines
drivers/scsi/iscsi_tcp.c +2 -1
@@ -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);

Alternatively, you could also just pass ISCSI_HOST_PARAM_IPADDRESS in place of the cast (since in this case param == ISCSI_HOST_PARAM_IPADDRESS), but I don't feel strongly about this (maybe the maintainers do).

Quoted 6 lines
drivers/scsi/iscsi_tcp.c +0 -1
        default:
                return iscsi_host_get_param(shost, param, buf);
        }
--

2.19.0

Signature · 2 lines
Thanks,
~Nick Desaulniers