|SUCCESS| examples/vm_power_manager: fix const discarding
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Apr 1 21:17:18 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/162807
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-01
Commit: [git sha not visible in patch]
Author: Thomas Monjalon <thomas at monjalon.net>
Subject: [PATCH] examples/vm_power_manager: fix const discarding
This patch removes the helper function get_resource_name_from_chn_path()
and replaces its single call site with a direct call to strstr(). This
addresses a GCC 15.2.1 warning about discarding a const qualifier.
> 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;
> -}
The removed function returns a mutable char* pointing into a const string.
While this patch eliminates the const-discarding warning, the underlying
issue remains: strstr() returns a const-qualified pointer when given a
const-qualified input.
> -
> 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);
Does this code still discard const here? The strstr() call receives a
const char* from chan_info->channel_path, but resource_name appears to be
a non-const char*. While this eliminates the intermediate function, does
the assignment to resource_name still violate const correctness?
Would it be more appropriate to either:
1) Change resource_name to const char* if it's only used for reading, or
2) Use strchr()/strstr() with proper const handling if modification is
needed?
Can you verify how resource_name is used after this assignment to confirm
whether const qualification is appropriate?
More information about the test-report
mailing list