Netdev List
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: Hangbin Liu <liuhangbin@gmail.com>
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 12:33:01 -0600	[thread overview]
Message-ID: <55fa5039-9273-3f5e-f911-f4baf1b01a4b@kernel.org> (raw)
In-Reply-To: <YzPrjj0h0o0Imsvy@Laptop-X1>

On 9/28/22 11:37 PM, Hangbin Liu wrote:
> 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()?
> 

I do not recall why '-2'. Seems arbitrary to me.

      reply	other threads:[~2022-09-28 18:33 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
2022-09-28 18:33     ` David Ahern [this message]

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=55fa5039-9273-3f5e-f911-f4baf1b01a4b@kernel.org \
    --to=dsahern@kernel.org \
    --cc=gnault@redhat.com \
    --cc=liuhangbin@gmail.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