Re: [PATCH V2] sfc: ef10: Fix assigning negative value to unsigned variable

From: Edward Cree
Date: Mon Apr 11 2022 - 12:27:12 EST


On 11/04/2022 02:32, Haowen Bai wrote:
> fix warning reported by smatch:
> 251 drivers/net/ethernet/sfc/ef10.c:2259 efx_ef10_tx_tso_desc()
> warn: assigning (-208) to unsigned variable 'ip_tot_len'
>
> Signed-off-by: Haowen Bai <baihaowen@xxxxxxxxx>
> ---
Acked-by: Edward Cree <ecree.xilinx@xxxxxxxxx>

> V1->V2: to assign "0x10000 - EFX_TSO2_MAX_HDRLEN" is the actual
> semantics of the value.
>
> drivers/net/ethernet/sfc/ef10.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
> index 50d535981a35..c9ee5011803f 100644
> --- a/drivers/net/ethernet/sfc/ef10.c
> +++ b/drivers/net/ethernet/sfc/ef10.c
> @@ -2256,7 +2256,7 @@ int efx_ef10_tx_tso_desc(struct efx_tx_queue *tx_queue, struct sk_buff *skb,
> * guaranteed to satisfy the second as we only attempt TSO if
> * inner_network_header <= 208.
> */
> - ip_tot_len = -EFX_TSO2_MAX_HDRLEN;
> + ip_tot_len = 0x10000 - EFX_TSO2_MAX_HDRLEN;
> EFX_WARN_ON_ONCE_PARANOID(mss + EFX_TSO2_MAX_HDRLEN +
> (tcp->doff << 2u) > ip_tot_len);
>
>