[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YzPrjj0h0o0Imsvy@Laptop-X1>
Date: Wed, 28 Sep 2022 14:37:02 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: David Ahern <dsahern@...nel.org>
Cc: netdev@...r.kernel.org,
Stephen Hemminger <stephen@...workplumber.org>,
Guillaume Nault <gnault@...hat.com>
Subject: Re: [PATCH iproute2-next] rtnetlink: add new function
rtnl_echo_talk()
Hi David,
On Tue, Sep 27, 2022 at 09:12:35PM -0600, David Ahern wrote:
> >
> > - if (echo_request)
> > - ret = rtnl_talk(&rth, &req.n, &answer);
> > - else
> > - ret = rtnl_talk(&rth, &req.n, NULL);
> > -
> > - if (ret < 0)
> > - return -2;
> > -
> > - if (echo_request) {
> > - new_json_obj(json);
> > - open_json_object(NULL);
> > - print_addrinfo(answer, stdout);
> > - close_json_object();
> > - delete_json_obj();
> > - free(answer);
> > - }
> > -
> > - return 0;
> > + return rtnl_echo_talk(&rth, &req.n, print_addrinfo);
>
> I was thinking something more like:
>
> if (echo_request)
> return rtnl_echo_talk(&rth, &req.n, print_addrinfo);
>
> return rtnl_talk(&rth, &req.n, NULL);
OK, I will update the patch. I have one question about the return value.
In previous code, the function return -2 if rtnl_talk() fails. I don't know
why we use "-2" here. And you suggested to just return rtnl_talk() directly.
Does this means we can ignore the -2 return values for all the places safely,
and just return rtnl_talk()?
Thanks
Hangbin
Powered by blists - more mailing lists