[PATCH 1/2] cmdline: add function to verify valid commands

Ray Kinsella mdr at ashroe.eu
Tue May 24 16:57:07 CEST 2022


Bruce Richardson <bruce.richardson at intel.com> writes:

> The cmdline library cmdline_parse() function parses a command and
> executes the action automatically too. The cmdline_valid_buffer function
> also uses this function to validate commands, meaning that there is no
> function to validate a command as ok without executing it.
>
> To fix this omission, we extract the body of cmdline_parse into a new
> static inline function with an extra parameter to indicate whether the
> action should be performed or not. Then we create two wrappers around
> that - a replacement for the existing cmdline_parse function where the
> extra parameter is "true" to execute the command, and a new function
> "cmdline_parse_check" which passes the parameter as "false" to perform
> cmdline validation only.
>
> Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
> ---
>  lib/cmdline/cmdline_parse.c | 20 +++++++++++++++++---
>  lib/cmdline/cmdline_parse.h | 17 +++++++++++++++--
>  lib/cmdline/version.map     |  3 +++
>  3 files changed, 35 insertions(+), 5 deletions(-)

Acked-by: Ray Kinsella <mdr at ashroe.eu>


More information about the stable mailing list