Subject: Re: [PATCH net-next v2 08/11] net/mlx5: devlink health: use retained error fmsg API

From: Simon Horman <[email-masked]>
Date: Wed, 18 Oct 2023 18:08:55 +0200

On Tue, Oct 17, 2023 at 12:53:38PM +0200, Przemek Kitszel wrote:
> Drop unneeded error checking.
> 
> devlink_fmsg_*() family of functions is now retaining errors,
> so there is no need to check for them after each call.
> 
> Reviewed-by: Jesse Brandeburg <[email-masked]>
> Signed-off-by: Przemek Kitszel <[email-masked]>

...

> @@ -288,52 +206,31 @@ int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key

Hi Przemek,

The code above this hunk looks like this:

        do {
                cmd_err = mlx5_rsc_dump_next(mdev, cmd, page, &size);
                if (cmd_err < 0) {
                        err = cmd_err;

clang-16 W=1 warns that err, which is used as the return value of the
function, will be uninitialised if the loop never hits this condition.

Smatch also warns about this.

>  			goto destroy_cmd;
>  		}
>  
> -		err = mlx5e_health_rsc_fmsg_binary(fmsg, page_address(page), size);
> -		if (err)
> -			goto destroy_cmd;
> -
> +		mlx5e_health_rsc_fmsg_binary(fmsg, page_address(page), size);
>  	} while (cmd_err > 0);
>  
>  destroy_cmd:
>  	mlx5_rsc_dump_cmd_destroy(cmd);
> -	end_err = devlink_fmsg_binary_pair_nest_end(fmsg);
> -	if (end_err)
> -		err = end_err;
> +	devlink_fmsg_binary_pair_nest_end(fmsg);
>  free_page:
>  	__free_page(page);
>  	return err;
>  }

...