Skip to contentSkip to conversation

IB/hfi1: Add explicit cast OPA_MTU_8192 to 'enum ib_mtu'

PATCH Applied Nathan Chancellor 3 participants 4 messages Jun 23, 2020 – Jul 2, 2020

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

PATCH 1/1 IB/hfi1: Add explicit cast OPA_MTU_8192 to 'enum ib_mtu'

Clang warns:

drivers/infiniband/hw/hfi1/qp.c:198:9: warning: implicit conversion from enumeration type 'enum opa_mtu' to different enumeration type 'enum ib_mtu' [-Wenum-conversion]

                mtu = OPA_MTU_8192;
                    ~ ^~~~~~~~~~~~

1 warning generated.

enum opa_mtu extends enum ib_mtu. There are typically two ways to deal with this:

* Remove the expected types and just use 'int' for all parameters and types.

* Explicitly cast the enums between each other.

This driver chooses to do the later so do the same thing here.

---
 drivers/infiniband/hw/hfi1/qp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/qp.c +1 -1
index 0c2ae9f7b3e8..2f3d9ce077d3 100644
@@ -195,7 +195,7 @@ static inline int verbs_mtu_enum_to_int(struct ib_device *dev, enum ib_mtu mtu)
 {
 	/* Constraining 10KB packets to 8KB packets */
 	if (mtu == (enum ib_mtu)OPA_MTU_10240)
-		mtu = OPA_MTU_8192;
+		mtu = (enum ib_mtu)OPA_MTU_8192;
 	return opa_mtu_enum_to_int((enum opa_mtu)mtu);
 }
 

base-commit: 27f11fea33608cbd321a97cbecfa2ef97dcc1821

Signature · 1 line
2.27.0
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · Nathan Chancellor

Clang warns:

drivers/infiniband/hw/hfi1/qp.c:198:9: warning: implicit conversion from enumeration type 'enum opa_mtu' to different enumeration type 'enum ib_mtu' [-Wenum-conversion]

                 mtu = OPA_MTU_8192;
                     ~ ^~~~~~~~~~~~

1 warning generated.

enum opa_mtu extends enum ib_mtu. There are typically two ways to deal with this:

* Remove the expected types and just use 'int' for all parameters and types.

* Explicitly cast the enums between each other.

Quoted 7 lines

This driver chooses to do the later so do the same thing here.

---

#2 lore raw
Quoted 20 lines · Dennis Dalessandro
Quoted 19 lines · Nathan Chancellor

Clang warns:

drivers/infiniband/hw/hfi1/qp.c:198:9: warning: implicit conversion from enumeration type 'enum opa_mtu' to different enumeration type 'enum ib_mtu' [-Wenum-conversion]

                 mtu = OPA_MTU_8192;
                     ~ ^~~~~~~~~~~~

1 warning generated.

enum opa_mtu extends enum ib_mtu. There are typically two ways to deal with this:

* Remove the expected types and just use 'int' for all parameters and types.

* Explicitly cast the enums between each other.

This driver chooses to do the later so do the same thing here.

Quoted 8 lines
Quoted 5 lines

---

Thanks! Who should pick up this patch? This warning is in mainline now, it would be nice if this could go via an -rc branch but if it is too late for that, I understand.

Cheers,
Nathan

maintainer Applied
#3 lore raw
In reply to Nathan Chancellor
Quoted 19 lines · Nathan Chancellor

Clang warns:

drivers/infiniband/hw/hfi1/qp.c:198:9: warning: implicit conversion from enumeration type 'enum opa_mtu' to different enumeration type 'enum ib_mtu' [-Wenum-conversion]

                mtu = OPA_MTU_8192;
                    ~ ^~~~~~~~~~~~

1 warning generated.

enum opa_mtu extends enum ib_mtu. There are typically two ways to deal with this:

* Remove the expected types and just use 'int' for all parameters and types.

* Explicitly cast the enums between each other.

This driver chooses to do the later so do the same thing here.

Quoted 8 lines
---
 drivers/infiniband/hw/hfi1/qp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-rc, thanks

Jason