[PATCH 06/13] lib: fwts_interactive: add sanity check on fileno, fix typo, tidy code
Colin King
colin.king at canonical.com
Tue Aug 14 11:24:28 UTC 2018
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;
}
-
--
2.17.1
More information about the fwts-devel
mailing list