netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: jiri@resnulli.us
Cc: stephen@networkplumber.org, netdev@vger.kernel.org
Subject: Re: [patch net-next] team: do not use -ENOENT
Date: Thu, 17 Jan 2013 16:07:42 -0500 (EST)	[thread overview]
Message-ID: <20130117.160742.614484345035625041.davem@davemloft.net> (raw)
In-Reply-To: <20130117205212.GB1591@minipsycho.orion>

From: Jiri Pirko <jiri@resnulli.us>
Date: Thu, 17 Jan 2013 21:52:12 +0100

> Thu, Jan 17, 2013 at 09:42:40PM CET, davem@davemloft.net wrote:
>>From: Jiri Pirko <jiri@resnulli.us>
>>Date: Thu, 17 Jan 2013 21:33:47 +0100
>>
>>>>> @@ -2320,7 +2320,7 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
>>>>>  			list_add(&opt_inst->tmp_list, &opt_inst_list);
>>>>>  		}
>>>>>  		if (!opt_found) {
>>>>> -			err = -ENOENT;
>>>>> +			err = -EINVAL;
>>>>>  			goto team_put;
>>>>>  		}
>>>>>  	}
>>
>>
>>> I'm not really sure. But in this case, I do not think that is a problem.
>>> 
>>> 1) I'm most probably the only one (libteam) who is using this api and
>>> libteam does not mind about what err code is returned in these cases.
>>> 
>>> 2) In this case, it is only about different number. And one number or
>>> another, it does not imply userspace to behave differently. In other words,
>>> userspace should not take different actions in case for example -ENOENT
>>> or -ENODEV is returned.
>>
>>I agree with this analysis.
>>
>>But for the team_nl_cmd_options_set() case, I would strongly advise
>>that you use some error code more descriptive than -EINVAL.  In fact
>>the existing -ENOENT I feel is better, because it tells the caller
>>what kind of problem there was.
>>
>>Even if you don't like the fact that -ENOENT is oriented towards file
>>existence, it does convey a ton more information than -EINVAL does.
> 
> I understand your feeling, because I have the same one :)
> But looking all over the code and on possible err codes as well, I did
> not find any suitable err code to indicate some object was not found.
> And since I recently saw email from Linus about the fact that -ENOENT
> should be used only in relation to files, -EINVAL the "default:" in my
> "switch()".

Look in the packet scheduler API for how much we use -ENOENT in this
kind of situation where the requested object to operate on could not
be found.

I think it is entirely appropriate to use -ENOENT, if not completely
consistent with the rest of the networking.

  reply	other threads:[~2013-01-17 21:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17 10:25 [patch net-next] team: do not use -ENOENT Jiri Pirko
2013-01-17 15:51 ` Stephen Hemminger
2013-01-17 20:33   ` Jiri Pirko
2013-01-17 20:42     ` David Miller
2013-01-17 20:52       ` Jiri Pirko
2013-01-17 21:07         ` David Miller [this message]
2013-01-17 21:15           ` Jiri Pirko
2013-01-17 21:18             ` David Miller

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=20130117.160742.614484345035625041.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=jiri@resnulli.us \
    --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;
as well as URLs for NNTP newsgroup(s).