[PATCH v12 3/3] app/testpmd: add sleep command
Stephen Hemminger
stephen at networkplumber.org
Sun Apr 5 18:48:10 CEST 2026
On Thu, 26 Feb 2026 16:44:50 +0000
Anatoly Burakov <anatoly.burakov at intel.com> wrote:
> +static void cmd_sleep_parsed(void *parsed_result,
> + __rte_unused struct cmdline *cl,
> + __rte_unused void *data)
> +{
> + struct cmd_sleep_result *res = parsed_result;
> +
> + rte_delay_us_sleep(res->secs * 1E6);
> +}
AI spotted something here
Error: rte_delay_us_sleep() takes unsigned int us.
The call rte_delay_us_sleep(res->secs * 1E6) silently converts a double to unsigned int.
If the user passes a negative value (which RTE_FLOAT_DOUBLE allows),
this is undefined behavior per C standard (negative floating point to unsigned integer conversion).
There should be a validation check that res->secs >= 0 (and ideally an upper bound) before the call.
More information about the dev
mailing list