<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 08/14/2018 07:24 PM, Colin King
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20180814112435.22166-7-colin.king@canonical.com">
<pre wrap="">From: Colin Ian King <a class="moz-txt-link-rfc2396E" href="mailto:colin.king@canonical.com"><colin.king@canonical.com></a>
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 <a class="moz-txt-link-rfc2396E" href="mailto:colin.king@canonical.com"><colin.king@canonical.com></a>
---
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;
}
-
</pre>
</blockquote>
<br>
Acked-by: Ivan Hu <a class="moz-txt-link-rfc2396E"
href="mailto:ivan.hu@canonical.com"><ivan.hu@canonical.com></a>
</body>
</html>