On Wed, Sep 26, 2018 at 10:46:37PM -0600, Jason Gunthorpe wrote: > On Wed, Sep 26, 2018 at 06:10:10PM -0700, Nathan Chancellor wrote: > > Clang warns when an emumerated type is implicitly converted to another. > > > > drivers/infiniband/sw/rxe/rxe.c:106:27: warning: implicit conversion > > from enumeration type 'enum rxe_device_param' to different enumeration > > type 'enum ib_atomic_cap' [-Wenum-conversion] > > rxe->attr.atomic_cap = RXE_ATOMIC_CAP; > > ~ ^~~~~~~~~~~~~~ > > drivers/infiniband/sw/rxe/rxe.c:131:22: warning: implicit conversion > > from enumeration type 'enum rxe_port_param' to different enumeration > > type 'enum ib_port_state' [-Wenum-conversion] > > port->attr.state = RXE_PORT_STATE; > > ~ ^~~~~~~~~~~~~~ > > drivers/infiniband/sw/rxe/rxe.c:132:24: warning: implicit conversion > > from enumeration type 'enum rxe_port_param' to different enumeration > > type 'enum ib_mtu' [-Wenum-conversion] > > port->attr.max_mtu = RXE_PORT_MAX_MTU; > > ~ ^~~~~~~~~~~~~~~~ > > drivers/infiniband/sw/rxe/rxe.c:133:27: warning: implicit conversion > > from enumeration type 'enum rxe_port_param' to different enumeration > > type 'enum ib_mtu' [-Wenum-conversion] > > port->attr.active_mtu = RXE_PORT_ACTIVE_MTU; > > ~ ^~~~~~~~~~~~~~~~~~~ > > drivers/infiniband/sw/rxe/rxe.c:151:24: warning: implicit conversion > > from enumeration type 'enum rxe_port_param' to different enumeration > > type 'enum ib_mtu' [-Wenum-conversion] > > ib_mtu_enum_to_int(RXE_PORT_ACTIVE_MTU); > > ~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~ > > 5 warnings generated. > > > > Mark all of these conversions as explicit to make it clear that this is > > expected behavior. All of these values are mapped to a value from the > > expected type. > > > > Reported-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> > > Signed-off-by: Nathan Chancellor <natechancellor@xxxxxxxxx> > > drivers/infiniband/sw/rxe/rxe.c | 11 ++++++----- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c > > index 10999fa69281..cac5e038449b 100644 > > +++ b/drivers/infiniband/sw/rxe/rxe.c > > @@ -103,7 +103,8 @@ static void rxe_init_device_param(struct rxe_dev *rxe) > > rxe->attr.max_res_rd_atom = RXE_MAX_RES_RD_ATOM; > > rxe->attr.max_qp_init_rd_atom = RXE_MAX_QP_INIT_RD_ATOM; > > rxe->attr.max_ee_init_rd_atom = RXE_MAX_EE_INIT_RD_ATOM; > > - rxe->attr.atomic_cap = RXE_ATOMIC_CAP; > > + rxe->attr.atomic_cap = > > + (enum ib_atomic_cap)RXE_ATOMIC_CAP; > > Yikes, this is just a bug in the rxe driver, it shouldn't be coded > like that, use IB_ATOMIC_HCA directly > > That giant thing in rxe_param.h is an abomination :( > > > rxe->attr.max_ee = RXE_MAX_EE; > > rxe->attr.max_rdd = RXE_MAX_RDD; > > rxe->attr.max_mw = RXE_MAX_MW; > > @@ -128,9 +129,9 @@ static void rxe_init_device_param(struct rxe_dev *rxe) > > /* initialize port attributes */ > > static int rxe_init_port_param(struct rxe_port *port) > > { > > - port->attr.state = RXE_PORT_STATE; > > - port->attr.max_mtu = RXE_PORT_MAX_MTU; > > - port->attr.active_mtu = RXE_PORT_ACTIVE_MTU; > > + port->attr.state = (enum ib_port_state)RXE_PORT_STATE; > > + port->attr.max_mtu = (enum ib_mtu)RXE_PORT_MAX_MTU; > > + port->attr.active_mtu = (enum ib_mtu)RXE_PORT_ACTIVE_MTU; > > Similar problem. > > > port->attr.gid_tbl_len = RXE_PORT_GID_TBL_LEN; > > port->attr.port_cap_flags = RXE_PORT_PORT_CAP_FLAGS; > > port->attr.max_msg_sz = RXE_PORT_MAX_MSG_SZ; > > @@ -148,7 +149,7 @@ static int rxe_init_port_param(struct rxe_port *port) > > port->attr.active_speed = RXE_PORT_ACTIVE_SPEED; > > port->attr.phys_state = RXE_PORT_PHYS_STATE; > > port->mtu_cap = > > - ib_mtu_enum_to_int(RXE_PORT_ACTIVE_MTU); > > + ib_mtu_enum_to_int((enum ib_mtu)RXE_PORT_ACTIVE_MTU); > > And again > > Jason Hi Jason, Thank you for the review, I will go ahead and use the proper enums from their respective types in v2. Nathan