Subject: Re: [PATCH net-next v4 1/5] net/sched: act_pedit: simplify 'ex' key parsing error propagation

From: Jakub Kicinski <[email-masked]>
Date: Thu, 20 Apr 2023 19:33:15 -0700

On Tue, 18 Apr 2023 20:43:50 -0300 Pedro Tammela wrote:
> 'err' is returned -EINVAL most of the time.
> Make the exception be the netlink parsing and remove the
> redundant error assignments in the other code paths.

> diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> index 4559a1507ea5..90f5214e679e 100644
> --- a/net/sched/act_pedit.c
> +++ b/net/sched/act_pedit.c
> @@ -54,46 +54,39 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
>  
>  	nla_for_each_nested(ka, nla, rem) {
>  		struct nlattr *tb[TCA_PEDIT_KEY_EX_MAX + 1];
> +		int ret;
>  
> -		if (!n) {
> -			err = -EINVAL;
> +		if (!n)
>  			goto err_out;
> -		}
>  		n--;

IMHO this is not worth doing. Setting the error value before the jump
is more idiomatic. If anything I'd remove the unnecessary init of err
to EINVAL at the start of the function.