diff mbox series

[net-next,1/2] net/ice: Fix boolean assignment

Message ID 20211130181243.3707618-2-anthony.l.nguyen@intel.com (mailing list archive)
State Not Applicable
Headers show
Series 100GbE Intel Wired LAN Driver Updates 2021-11-30 | expand

Commit Message

Tony Nguyen Nov. 30, 2021, 6:12 p.m. UTC
From: Shiraz Saleem <shiraz.saleem@intel.com>

vbool in ice_devlink_enable_roce_get can be assigned to a
non-0/1 constant.

Fix this assignment of vbool to be 0/1.

Fixes: e523af4ee560 ("net/ice: Add support for enable_iwarp and enable_roce devlink param")
Suggested-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_devlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joe Perches Dec. 2, 2021, 5:49 p.m. UTC | #1
On Tue, 2021-11-30 at 10:12 -0800, Tony Nguyen wrote:
> From: Shiraz Saleem <shiraz.saleem@intel.com>
> 
> vbool in ice_devlink_enable_roce_get can be assigned to a
> non-0/1 constant.
> 
> Fix this assignment of vbool to be 0/1.

This one seems fine, but another use of vbool in ice still exists

drivers/net/ethernet/intel/ice/ice_devlink.c:617:       value.vbool = test_bit(ICE_FLAG_RDMA_ENA, pf->flags) ? true : false;

Curiously, the vbool is defined in a union so it's possible
for the vbool value in the union to not just be 0 or 1.

> diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c
[]
> @@ -436,7 +436,7 @@ ice_devlink_enable_roce_get(struct devlink *devlink, u32 id,
>  {
>  	struct ice_pf *pf = devlink_priv(devlink);
>  
> -	ctx->val.vbool = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2;
> +	ctx->val.vbool = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ? true : false;
>  
>  	return 0;
>  }
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c
index 478412b28a76..1cfe918db8b9 100644
--- a/drivers/net/ethernet/intel/ice/ice_devlink.c
+++ b/drivers/net/ethernet/intel/ice/ice_devlink.c
@@ -436,7 +436,7 @@  ice_devlink_enable_roce_get(struct devlink *devlink, u32 id,
 {
 	struct ice_pf *pf = devlink_priv(devlink);
 
-	ctx->val.vbool = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2;
+	ctx->val.vbool = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ? true : false;
 
 	return 0;
 }