[PATCH] examples/vm_power_manager: fix const discarding

Thomas Monjalon thomas at monjalon.net
Wed Apr 1 11:35:01 CEST 2026


When compiling with GCC 15.2.1, a const qualifier issue
is seen with this warning:

In function 'get_resource_name_from_chn_path':
examples/vm_power_manager/channel_monitor.c:139:16:
error: assignment discards 'const' qualifier from pointer target type
  139 |         substr = strstr(channel_path, CHANNEL_MGR_FIFO_PATTERN_NAME);
      |                ^

The function get_resource_name_from_chn_path is used only once
and call a single function (strstr),
so it can be replaced with a direct call to strstr().

Fixes: 221e7026d521 ("examples/power: add FIFO per core for JSON interface")
Cc: stable at dpdk.org

Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
---
 examples/vm_power_manager/channel_monitor.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c
index 800f733a26..3023e444a4 100644
--- a/examples/vm_power_manager/channel_monitor.c
+++ b/examples/vm_power_manager/channel_monitor.c
@@ -131,16 +131,6 @@ set_policy_mac(struct rte_power_channel_packet *pkt, int idx, char *mac)
 	return 0;
 }
 
-static char*
-get_resource_name_from_chn_path(const char *channel_path)
-{
-	char *substr = NULL;
-
-	substr = strstr(channel_path, CHANNEL_MGR_FIFO_PATTERN_NAME);
-
-	return substr;
-}
-
 static int
 get_resource_id_from_vmname(const char *vm_name)
 {
@@ -1066,8 +1056,8 @@ read_json_packet(struct channel_info *chan_info)
 		root = json_loads(json_data, 0, &error);
 
 		if (root) {
-			resource_name = get_resource_name_from_chn_path(
-				chan_info->channel_path);
+			resource_name = strstr(chan_info->channel_path,
+					CHANNEL_MGR_FIFO_PATTERN_NAME);
 			/*
 			 * Because our data is now in the json
 			 * object, we can overwrite the pkt
-- 
2.53.0



More information about the stable mailing list