summaryrefslogtreecommitdiffstats
path: root/term-utils
diff options
context:
space:
mode:
authorKarel Zak2012-06-21 12:03:27 +0200
committerKarel Zak2012-06-21 12:13:08 +0200
commitefcf26f44f13e74046cd17a902284bb491619da9 (patch)
tree1b9eae4e1c3daac845ba7ceafd0e172069b3f088 /term-utils
parentlsblk: check ioctl result [coverity scan] (diff)
downloadkernel-qcow2-util-linux-efcf26f44f13e74046cd17a902284bb491619da9.tar.gz
kernel-qcow2-util-linux-efcf26f44f13e74046cd17a902284bb491619da9.tar.xz
kernel-qcow2-util-linux-efcf26f44f13e74046cd17a902284bb491619da9.zip
agetty: more robust debug() macro, check ioctl result [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils')
-rw-r--r--term-utils/agetty.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 862b8c49d..7514015f6 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -264,11 +264,11 @@ static void login_options_to_argv(char *argv[], int *argc, char *str, char *user
static char *fakehost;
#ifdef DEBUGGING
-#define debug(s) fprintf(dbf,s); fflush(dbf)
+#define debug(s) do { fprintf(dbf,s); fflush(dbf); while (0)
FILE *dbf;
#else
-#define debug(s)
-#endif /* DEBUGGING */
+#define debug(s) do { ; } while (0)
+#endif
int main(int argc, char **argv)
{
@@ -929,7 +929,8 @@ static void open_tty(char *tty, struct termios *tp, struct options *op)
*/
if (vhangup())
log_err("/dev/%s: vhangup() failed: %m", tty);
- ioctl(fd, TIOCNOTTY);
+ if (ioctl(fd, TIOCNOTTY))
+ debug("TIOCNOTTY ioctl failed\n");
}
close(fd);
@@ -1114,7 +1115,8 @@ static void termio_init(struct options *op, struct termios *tp)
ws.ws_col = 80;
set++;
}
- ioctl(STDIN_FILENO, TIOCSWINSZ, &ws);
+ if (ioctl(STDIN_FILENO, TIOCSWINSZ, &ws))
+ debug("TIOCSWINSZ ioctl failed\n");
}
/* Optionally enable hardware flow control. */