From efcf26f44f13e74046cd17a902284bb491619da9 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 21 Jun 2012 12:03:27 +0200 Subject: agetty: more robust debug() macro, check ioctl result [coverity scan] Signed-off-by: Karel Zak --- term-utils/agetty.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'term-utils/agetty.c') 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. */ -- cgit v1.2.3-55-g7522