ACK: [PATCH 06/13] lib: fwts_interactive: add sanity check on fileno, fix typo, tidy code
ivanhu
ivan.hu at canonical.com
Thu Aug 16 09:04:03 UTC 2018
On 08/14/2018 07:24 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> However unlikely, we should add a sanity check on the return from
> fileno just in case it failed. Fix a typo in a comment and remove
> an empty line.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_interactive.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/lib/src/fwts_interactive.c b/src/lib/src/fwts_interactive.c
> index 5a8e873e..d1aa70fe 100644
> --- a/src/lib/src/fwts_interactive.c
> +++ b/src/lib/src/fwts_interactive.c
> @@ -33,9 +33,11 @@ static int fwts_getchar(int *ch)
> {
> struct termios oldterm;
> struct termios newterm;
> - int fd = fileno(stdin);
> + const int fd = fileno(stdin);
>
> *ch = -1;
> + if (fd < 0)
> + return FWTS_ERROR;
>
> if (tcgetattr(fd, &oldterm) < 0)
> return FWTS_ERROR;
> @@ -76,7 +78,7 @@ int fwts_printf(fwts_framework *fw, const char *fmt, ...)
> }
>
> /*
> - * fwts_press_entrer()
> + * fwts_press_enter()
> * prompt and wait for enter key
> */
> int fwts_press_enter(fwts_framework *fw)
> @@ -111,7 +113,6 @@ int fwts_get_reply(fwts_framework *fw, const char *message, const char *options)
> fflush(stdout);
>
> for (;;) {
> -
> if (fwts_getchar(&ch) == FWTS_ERROR) {
> fwts_log_error(fw, "fwts_getchar() failed.");
> break;
> @@ -124,4 +125,3 @@ int fwts_get_reply(fwts_framework *fw, const char *message, const char *options)
>
> return ch;
> }
> -
Acked-by: Ivan Hu <ivan.hu at canonical.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20180816/cb5a450f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20180816/cb5a450f/attachment-0001.sig>
More information about the fwts-devel
mailing list