DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH] examples/multi_process: check return value from get name
Date: Fri, 20 Nov 2026 11:13:26 -0800	[thread overview]
Message-ID: <20261120191326.4052618-1-stephen@networkplumber.org> (raw)

Better to use the return value of rte_eth_dev_get_name_by_port()
rather than depending on side effect of name being set or not.

Coverity ID: 511674

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/multi_process/hotplug_mp/commands.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/examples/multi_process/hotplug_mp/commands.c b/examples/multi_process/hotplug_mp/commands.c
index e84e130b3c..b4cd073a4b 100644
--- a/examples/multi_process/hotplug_mp/commands.c
+++ b/examples/multi_process/hotplug_mp/commands.c
@@ -35,13 +35,14 @@ cmd_list_parsed(__rte_unused void *parsed_result,
 	cmdline_printf(cl, "list all etherdev\n");
 
 	RTE_ETH_FOREACH_DEV(port_id) {
-		char dev_name[RTE_DEV_NAME_MAX_LEN] = "";
+		char dev_name[RTE_DEV_NAME_MAX_LEN];
+		int ret;
 
-		rte_eth_dev_get_name_by_port(port_id, dev_name, sizeof(dev_name));
-		if (strlen(dev_name) > 0)
-			cmdline_printf(cl, "%d\t%s\n", port_id, dev_name);
+		ret = rte_eth_dev_get_name_by_port(port_id, dev_name, sizeof(dev_name));
+		if (ret == 0)
+			cmdline_printf(cl, "%u\t%s\n", port_id, dev_name);
 		else
-			printf("empty dev_name is not expected!\n");
+			cmdline_printf(cl, "%u\error - %s\n", port_id, strerror(-ret));
 	}
 }
 
-- 
2.53.0


                 reply	other threads:[~2026-11-20 19:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261120191326.4052618-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.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