Re: [PATCH] net: Remove a local variable with the same name as the parameter.
From: Eric Dumazet
Date: Mon Aug 26 2024 - 04:33:36 EST
On Mon, Aug 26, 2024 at 9:42 AM jiping huang <huangjiping95@xxxxxx> wrote:
>
> There is no need to use an additional local avariable to get rtmsg.flags,
> and this variable has the same name as the function argument.
>
> Signed-off-by: jiping huang <huangjiping95@xxxxxx>
>
> diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
> index f669da98d11d..0d69267c9971 100644
> --- a/net/ipv4/fib_semantics.c
> +++ b/net/ipv4/fib_semantics.c
> @@ -1830,12 +1830,10 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
>
> if (nhs == 1) {
> const struct fib_nh_common *nhc = fib_info_nhc(fi, 0);
> - unsigned char flags = 0;
>
> - if (fib_nexthop_info(skb, nhc, AF_INET, &flags, false) < 0)
> + if (fib_nexthop_info(skb, nhc, AF_INET, &rtm->rtm_flags, false) < 0)
> goto nla_put_failure;
>
> - rtm->rtm_flags = flags;
> #ifdef CONFIG_IP_ROUTE_CLASSID
> if (nhc->nhc_family == AF_INET) {
> struct fib_nh *nh;
Wrong patch, please read fib_nexthop_info(), it does not clear *flags at entry.