netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, dsahern@gmail.com
Subject: [patch iproute2-next 4/6] devlink: return -ENOENT if argument is missing
Date: Thu, 31 Aug 2023 15:22:27 +0200	[thread overview]
Message-ID: <20230831132229.471693-5-jiri@resnulli.us> (raw)
In-Reply-To: <20230831132229.471693-1-jiri@resnulli.us>

From: Jiri Pirko <jiri@nvidia.com>

In preparation to the follow-up dump selector patch, make sure that the
command line arguments parsing function returns -ENOENT in case the
option is missing so the caller can distinguish.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
 devlink/devlink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 8d2424f58cc2..6a46a4ecf648 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1048,7 +1048,7 @@ static int strtobool(const char *str, bool *p_val)
 static int ident_str_validate(char *str, unsigned int expected)
 {
 	if (!str)
-		return -EINVAL;
+		return -ENOENT;
 
 	if (get_str_char_count(str, '/') != expected) {
 		pr_err("Wrong identification string format.\n");
@@ -1131,7 +1131,7 @@ static int dl_argv_handle_port(struct dl *dl, char *str, char **p_bus_name,
 
 	if (!str) {
 		pr_err("Port identification (\"bus_name/dev_name/port_index\" or \"netdev ifname\") expected.\n");
-		return -EINVAL;
+		return -ENOENT;
 	}
 	slash_count = get_str_char_count(str, '/');
 	switch (slash_count) {
@@ -1159,7 +1159,7 @@ static int dl_argv_handle_both(struct dl *dl, char *str, char **p_bus_name,
 		pr_err("One of following identifications expected:\n"
 		       "Devlink identification (\"bus_name/dev_name\")\n"
 		       "Port identification (\"bus_name/dev_name/port_index\" or \"netdev ifname\")\n");
-		return -EINVAL;
+		return -ENOENT;
 	}
 	slash_count = get_str_char_count(str, '/');
 	if (slash_count == 1) {
@@ -1681,7 +1681,7 @@ static int dl_args_finding_required_validate(uint64_t o_required,
 		o_flag = dl_args_required[i].o_flag;
 		if ((o_required & o_flag) && !(o_found & o_flag)) {
 			pr_err("%s\n", dl_args_required[i].err_msg);
-			return -EINVAL;
+			return -ENOENT;
 		}
 	}
 	if (o_required & ~o_found) {
-- 
2.41.0


  parent reply	other threads:[~2023-08-31 13:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31 13:22 [patch iproute2-next 0/6] devlink: implement dump selector for devlink objects show commands Jiri Pirko
2023-08-31 13:22 ` [patch iproute2-next 1/6] devlink: move DL_OPT_SB into required options Jiri Pirko
2023-08-31 13:22 ` [patch iproute2-next 2/6] devlink: make parsing of handle non-destructive to argv Jiri Pirko
2023-08-31 13:22 ` [patch iproute2-next 3/6] devlink: implement command line args dry parsing Jiri Pirko
2023-08-31 13:22 ` Jiri Pirko [this message]
2023-08-31 13:22 ` [patch iproute2-next 5/6] mnl_utils: introduce a helper to check if dump policy exists for command Jiri Pirko
2023-08-31 13:22 ` [patch iproute2-next 6/6] devlink: implement dump selector for devlink objects show commands Jiri Pirko
2023-09-04  9:33 ` [patch iproute2-next 0/6] " Jiri Pirko

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=20230831132229.471693-5-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=dsahern@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;
as well as URLs for NNTP newsgroup(s).