From: Hangbin Liu <liuhangbin@gmail.com>
To: David Ahern <dsahern@kernel.org>
Cc: netdev@vger.kernel.org,
Stephen Hemminger <stephen@networkplumber.org>,
Guillaume Nault <gnault@redhat.com>
Subject: Re: [PATCH iproute2-next] rtnetlink: add new function rtnl_echo_talk()
Date: Wed, 28 Sep 2022 14:37:02 +0800 [thread overview]
Message-ID: <YzPrjj0h0o0Imsvy@Laptop-X1> (raw)
In-Reply-To: <115c54d7-87fc-2c50-bc27-ad7cdb27bb2c@kernel.org>
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
next prev parent reply other threads:[~2022-09-28 6:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-23 4:20 [PATCH iproute2-next] rtnetlink: add new function rtnl_echo_talk() Hangbin Liu
2022-09-28 3:12 ` David Ahern
2022-09-28 6:37 ` Hangbin Liu [this message]
2022-09-28 18:33 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YzPrjj0h0o0Imsvy@Laptop-X1 \
--to=liuhangbin@gmail.com \
--cc=dsahern@kernel.org \
--cc=gnault@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox