* [PATCH] examples/multi_process: check return value from get name
@ 2026-11-20 19:13 Stephen Hemminger
2026-11-22 17:35 ` [PATCH v2] " Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2026-11-20 19:13 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] examples/multi_process: check return value from get name
2026-11-20 19:13 [PATCH] examples/multi_process: check return value from get name Stephen Hemminger
@ 2026-11-22 17:35 ` Stephen Hemminger
2026-11-23 8:52 ` Bruce Richardson
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2026-11-22 17:35 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Anatoly Burakov, Qi Zhang
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 issue: 511674
Fixes: 05f1d6842fc3 ("examples/multi_process: add hotplug sample")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - fix printf format typo, and commit message
examples/multi_process/hotplug_mp/commands.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/examples/multi_process/hotplug_mp/commands.c b/examples/multi_process/hotplug_mp/commands.c
index e84e130b3c..7179a5bf8e 100644
--- a/examples/multi_process/hotplug_mp/commands.c
+++ b/examples/multi_process/hotplug_mp/commands.c
@@ -2,6 +2,8 @@
* Copyright(c) 2018-2023 Intel Corporation.
*/
+#include <string.h>
+
#include <rte_bus.h>
#include <rte_ethdev.h>
#include "commands.h"
@@ -35,13 +37,15 @@ 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, "No name for port %u: %s\n",
+ port_id, strerror(-ret));
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] examples/multi_process: check return value from get name
2026-11-22 17:35 ` [PATCH v2] " Stephen Hemminger
@ 2026-11-23 8:52 ` Bruce Richardson
0 siblings, 0 replies; 3+ messages in thread
From: Bruce Richardson @ 2026-11-23 8:52 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Anatoly Burakov, Qi Zhang
On Sun, Nov 22, 2026 at 09:35:20AM -0800, Stephen Hemminger wrote:
> 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 issue: 511674
> Fixes: 05f1d6842fc3 ("examples/multi_process: add hotplug sample")
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v2 - fix printf format typo, and commit message
>
> examples/multi_process/hotplug_mp/commands.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Don't think this needs to go in 26.11, but LGTM for 27.03 merge.
/Bruce
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 8:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 19:13 [PATCH] examples/multi_process: check return value from get name Stephen Hemminger
2026-11-22 17:35 ` [PATCH v2] " Stephen Hemminger
2026-11-23 8:52 ` Bruce Richardson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox