Skip to contentSkip to conversation

examples/vm_power_manager: fix const discarding

PATCH In review Thomas Monjalon 1 participant 2 messages Apr 1 – Apr 8

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/vm_power_manager: fix const discarding

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")
---
 examples/vm_power_manager/channel_monitor.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
examples/vm_power_manager/channel_monitor.c +2 -12
index 800f733a26..3023e444a4 100644
@@ -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
Signature · 1 line
2.53.0
#1 lore raw

01/04/2026 11:35, Thomas Monjalon:

Quoted 9 lines

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);
| ^

Quoted 8 lines

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")

Applied to fix building with a recent GCC.