mthca: work around -Wenum-conversion warning
PATCH 1/1 mthca: work around -Wenum-conversion warning
From: Arnd Bergmann <[email protected]>
gcc points out a suspicious mixing of enum types in a function that converts from MTHCA_OPCODE_* values to IB_WC_* values:
drivers/infiniband/hw/mthca/mthca_cq.c: In function 'mthca_poll_one':drivers/infiniband/hw/mthca/mthca_cq.c:607:21: warning: implicit conversion from 'enum <anonymous>' to 'enum ib_wc_opcode' [-Wenum-conversion]
607 | entry->opcode = MTHCA_OPCODE_INVALID;
Nothing seems to ever check for MTHCA_OPCODE_INVALID again, no idea if this is meaningful, but it seems harmless as it deals with an invalid input.
Add a cast to suppress the warning.
--- drivers/infiniband/hw/mthca/mthca_cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mthca/mthca_cq.c +1 -1
@@ -604,7 +604,7 @@ static inline int mthca_poll_one(struct mthca_dev *dev, entry->byte_len =MTHCA_ATOMIC_BYTE_LEN ;break ;default : - entry->opcode =MTHCA_OPCODE_INVALID ; + entry->opcode = (u8 )MTHCA_OPCODE_INVALID ;break ; } }else {
Signature · 1 line
2.27.0
Jason Gunthorpe
maintainerQuoted 24 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc points out a suspicious mixing of enum types in a function that converts from MTHCA_OPCODE_* values to IB_WC_* values:
drivers/infiniband/hw/mthca/mthca_cq.c: In function 'mthca_poll_one':drivers/infiniband/hw/mthca/mthca_cq.c:607:21: warning: implicit conversion from 'enum <anonymous>' to 'enumib_wc_opcode' [-Wenum-conversion]
607 |entry->opcode=MTHCA_OPCODE_INVALID;Nothing seems to ever check for
MTHCA_OPCODE_INVALIDagain, no idea if this is meaningful, but it seems harmless as it deals with an invalid input.Add a cast to suppress the warning.
Fixes 2a4443a69934 ("[PATCH] IB/mthca: fill in opcode field for send completions")Signed-off-by Arnd Bergmann <[email protected]>drivers/infiniband/hw/mthca/mthca_cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/mthca/mthca_cq.c +1
-0+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
drivers/infiniband/hw/mthca/mthca_cq.c static inline int mthca_poll_one(struct mthca_dev *dev, · line 608
Quoted 6 lines
drivers/infiniband/hw/mthca/mthca_cq.c +1
-1@@ -604,7 +604,7 @@ static inline int mthca_poll_one(struct mthca_dev *dev, entry->byte_len =MTHCA_ATOMIC_BYTE_LEN ;break ;default : - entry->opcode =MTHCA_OPCODE_INVALID ; + entry->opcode = (u8 )MTHCA_OPCODE_INVALID ;break ;
This code is completely bogus, sigh
Is this OK as far as the warning goes?
drivers/infiniband/hw/mthca/mthca_cq.c +1 -1
@@ -604,7 +604,7 @@ static inline int mthca_poll_one(struct mthca_dev *dev, entry->byte_len =MTHCA_ATOMIC_BYTE_LEN ;break ;default : - entry->opcode = (u8 )MTHCA_OPCODE_INVALID ; + entry->opcode =0xFF ;break ; } }else {
drivers/infiniband/hw/mthca/mthca_dev.h +0 -1
@@ -105,7 +105,6 @@ enum {MTHCA_OPCODE_ATOMIC_CS =0x11 ,MTHCA_OPCODE_ATOMIC_FA =0x12 , MTHCA_OPCODE_BIND_MW = 0x18, -MTHCA_OPCODE_INVALID =0xff }; enum {
Arnd Bergmann
Acked-byQuoted 35 lines · Jason Gunthorpe
Quoted 24 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc points out a suspicious mixing of enum types in a function that converts from MTHCA_OPCODE_* values to IB_WC_* values:
drivers/infiniband/hw/mthca/mthca_cq.c: In function 'mthca_poll_one':drivers/infiniband/hw/mthca/mthca_cq.c:607:21: warning: implicit conversion from 'enum <anonymous>' to 'enumib_wc_opcode' [-Wenum-conversion]
607 |entry->opcode=MTHCA_OPCODE_INVALID;Nothing seems to ever check for
MTHCA_OPCODE_INVALIDagain, no idea if this is meaningful, but it seems harmless as it deals with an invalid input.Add a cast to suppress the warning.
Fixes 2a4443a69934 ("[PATCH] IB/mthca: fill in opcode field for send completions")Signed-off-by Arnd Bergmann <[email protected]>drivers/infiniband/hw/mthca/mthca_cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/mthca/mthca_cq.c +1
-0+++ b/drivers/infiniband/hw/mthca/mthca_cq.cdrivers/infiniband/hw/mthca/mthca_cq.c static inline int mthca_poll_one(struct mthca_dev *dev, · line 608
Quoted 6 lines
drivers/infiniband/hw/mthca/mthca_cq.c +1
-1@@ -604,7 +604,7 @@ static inline int mthca_poll_one(struct mthca_dev *dev, entry->byte_len =MTHCA_ATOMIC_BYTE_LEN ;break ;default : - entry->opcode =MTHCA_OPCODE_INVALID ; + entry->opcode = (u8 )MTHCA_OPCODE_INVALID ;break ;This code is completely bogus, sigh
Quoted 1 line
Is this OK as far as the warning goes?
Yes, I'm sure your patch fixes it and it makes more sense than my version.
Jason Gunthorpe
maintainerQuoted 36 lines · Arnd Bergmann
Quoted 35 lines · Jason Gunthorpe
Quoted 24 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc points out a suspicious mixing of enum types in a function that converts from MTHCA_OPCODE_* values to IB_WC_* values:
drivers/infiniband/hw/mthca/mthca_cq.c: In function 'mthca_poll_one':drivers/infiniband/hw/mthca/mthca_cq.c:607:21: warning: implicit conversion from 'enum <anonymous>' to 'enumib_wc_opcode' [-Wenum-conversion]
607 |entry->opcode=MTHCA_OPCODE_INVALID;Nothing seems to ever check for
MTHCA_OPCODE_INVALIDagain, no idea if this is meaningful, but it seems harmless as it deals with an invalid input.Add a cast to suppress the warning.
Fixes 2a4443a69934 ("[PATCH] IB/mthca: fill in opcode field for send completions")Signed-off-by Arnd Bergmann <[email protected]>drivers/infiniband/hw/mthca/mthca_cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/mthca/mthca_cq.c +1
-0+++ b/drivers/infiniband/hw/mthca/mthca_cq.cdrivers/infiniband/hw/mthca/mthca_cq.c static inline int mthca_poll_one(struct mthca_dev *dev, · line 608
Quoted 6 lines
drivers/infiniband/hw/mthca/mthca_cq.c +1
-1@@ -604,7 +604,7 @@ static inline int mthca_poll_one(struct mthca_dev *dev, entry->byte_len =MTHCA_ATOMIC_BYTE_LEN ;break ;default : - entry->opcode =MTHCA_OPCODE_INVALID ; + entry->opcode = (u8 )MTHCA_OPCODE_INVALID ;break ;This code is completely bogus, sigh
Quoted 5 lines
Quoted 1 line
Is this OK as far as the warning goes?
Yes, I'm sure your patch fixes it and it makes more sense than my version.
Acked-by Arnd Bergmann <[email protected]>
Okay, I'll revise it, thanks
Jason