[PATCH v10 1/2] cmdline: handle EOF in cmdline_poll
Ferruh Yigit
ferruh.yigit at amd.com
Mon Jan 30 23:12:42 CET 2023
On 1/30/2023 8:09 PM, Stephen Hemminger wrote:
> If end of file is reached on input, then cmdline_read_char()
> will return 0. The problem is that cmdline_poll() was not checking
> for this and would continue and not return the status.
>
> Fixes: 9251cd97a6be ("cmdline: add internal wrappers for character input")
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
> lib/cmdline/cmdline.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c
> index e1009ba4c413..de41406d61e0 100644
> --- a/lib/cmdline/cmdline.c
> +++ b/lib/cmdline/cmdline.c
> @@ -194,7 +194,7 @@ cmdline_poll(struct cmdline *cl)
> else if (status > 0) {
> c = -1;
> read_status = cmdline_read_char(cl, &c);
> - if (read_status < 0)
> + if (read_status <= 0)
> return read_status;
According API doc it will be wrong to return '0', which imply 'RDLINE_INIT'.
But function may return any negative value on error, what about to get
eof as and error case:
if (read_status < 0)
return read_status;
else if (read_status == 0)
return -EIO;
With this 'cmdline_poll()' can be used in testpmd as it is used in v9 of
this patch:
while (f_quit == 0 && cl_quit == 0) {
if (cmdline_poll(cl) < 0)
break;
}
But still I guess this is an ABI break because of API behavior change.
More information about the dev
mailing list