netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Parav Pandit <parav@nvidia.com>
To: <dsahern@gmail.com>, <stephen@networkplumber.org>,
	<netdev@vger.kernel.org>
Cc: Parav Pandit <parav@nvidia.com>
Subject: [PATCH iproute2-next 4/4] devlink: Add error print when unknown values specified
Date: Mon, 1 Mar 2021 12:56:54 +0200	[thread overview]
Message-ID: <20210301105654.291949-5-parav@nvidia.com> (raw)
In-Reply-To: <20210301105654.291949-1-parav@nvidia.com>

When user specifies either unknown flavour or unknown state during
devlink port commands, return appropriate error message.

Signed-off-by: Parav Pandit <parav@nvidia.com>
---
 devlink/devlink.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index eaac1806..16eca4f9 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1372,8 +1372,10 @@ static int port_flavour_parse(const char *flavour, uint16_t *value)
 	int num;
 
 	num = str_map_lookup_str(port_flavour_map, flavour);
-	if (num < 0)
+	if (num < 0) {
+		invarg("unknown flavour", flavour);
 		return num;
+	}
 	*value = num;
 	return 0;
 }
@@ -1383,8 +1385,10 @@ static int port_fn_state_parse(const char *statestr, uint8_t *state)
 	int num;
 
 	num = str_map_lookup_str(port_fn_state_map, statestr);
-	if (num < 0)
+	if (num < 0) {
+		invarg("unknown state", statestr);
 		return num;
+	}
 	*state = num;
 	return 0;
 }
-- 
2.26.2


  parent reply	other threads:[~2021-03-01 10:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 10:56 [PATCH iproute2-next 0/4] devlink: Use utils helpers Parav Pandit
2021-03-01 10:56 ` [PATCH iproute2-next 1/4] devlink: Use library provided string processing APIs Parav Pandit
2021-03-01 10:56 ` [PATCH iproute2-next 2/4] utils: Introduce helper routines for generic socket recv Parav Pandit
2021-03-01 10:56 ` [PATCH iproute2-next 3/4] devlink: Use generic socket helpers from library Parav Pandit
2021-03-01 10:56 ` Parav Pandit [this message]
2021-03-03  4:02 ` [PATCH iproute2-next 0/4] devlink: Use utils helpers David Ahern
2021-03-03  4:10 ` patchwork-bot+netdevbpf

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=20210301105654.291949-5-parav@nvidia.com \
    --to=parav@nvidia.com \
    --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).