Re: [PATCH net-next v2 1/5] eea: Drop temporary buffer by using %*pEhp directly
From: Joe Damato
Date: Fri Oct 02 2026 - 16:50:49 EST
On Fri, Oct 02, 2026 at 11:59:19AM +0200, Andy Shevchenko wrote:
> Instead of calling string_escape_str() followed by %s specifier,
> use %*pEhp specifier directly. With this being done, drop temporary
> buffer.
>
> Note, as Sashiko pointed out in [1] the %*pEp, which is the direct
> substitution of the original call to string_escape_str() with ESCAPE_NP
> flag set, makes the whole thing like "no escape". To add some sanity
> to this the used specifier also includes ESCAPE_HEX.
>
> Link: https://lore.kernel.org/r/179089728102.434549.12368098081790653201@xxxxxxxxxx [1]
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
> drivers/net/ethernet/alibaba/eea/eea_adminq.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/alibaba/eea/eea_adminq.c b/drivers/net/ethernet/alibaba/eea/eea_adminq.c
> index 73d0caf25700..f2284fc885c3 100644
> --- a/drivers/net/ethernet/alibaba/eea/eea_adminq.c
> +++ b/drivers/net/ethernet/alibaba/eea/eea_adminq.c
> @@ -522,16 +522,9 @@ void eea_adminq_config_host_info(struct eea_net *enet)
> dev_warn(dev, "The hardware-driven state validation may be abnormal.\n");
>
> if (rep->has_reply) {
> - char buf[EEA_HINFO_MAX_REP_LEN] = {0};
> -
> rep->reply_str[EEA_HINFO_MAX_REP_LEN - 1] = '\0';
> -
> - string_escape_str(rep->reply_str, buf, sizeof(buf),
> - ESCAPE_NP, NULL);
> -
> - buf[EEA_HINFO_MAX_REP_LEN - 1] = '\0';
> -
> - dev_warn(dev, "Device replied: %s\n", buf);
> + dev_warn(dev, "Device replied: %*pEhp\n",
> + (int)strlen(rep->reply_str), rep->reply_str);
i have no idea what this otuput could be but i suppose if you wanted to remove
the terminator write above, you could do:
strnlen(rep->reply_str, ....)
instead, but that feels like a fairly useless nit so:
Reviewed-by: Joe Damato <joe@xxxxxxx>