]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: more robust debug() macro, check ioctl result [coverity scan]
authorKarel Zak <kzak@redhat.com>
Thu, 21 Jun 2012 10:03:27 +0000 (12:03 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 21 Jun 2012 10:13:08 +0000 (12:13 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c

index 862b8c49dd090e210e3644c86dbc08afba6d9900..7514015f65596ae96fa0b2439531ca7514f3158f 100644 (file)
@@ -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. */