]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sulogin: fix compiler warning [-Werror=implicit-fallthrough=]
authorKarel Zak <kzak@redhat.com>
Fri, 7 Jan 2022 12:49:40 +0000 (13:49 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 7 Jan 2022 12:49:40 +0000 (13:49 +0100)
and make sure errno is reset before read()

Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/sulogin.c

index 227826ffcf3653a757f0ef34fedb07d6b96dabd5..4c2daa6a4ade09b2f941efaeee4dffa77d142c1d 100644 (file)
@@ -698,7 +698,10 @@ static char *getpasswd(struct console *con)
        cp->eol = *ptr = '\0';
 
        eightbit = ((con->flags & CON_SERIAL) == 0 || (tty.c_cflag & (PARODD|PARENB)) == 0);
+
        while (cp->eol == '\0') {
+               errno = 0;
+
                if (read(fd, &c, 1) < 1) {
                        if (errno == EINTR || errno == EAGAIN) {
                                if (alarm_rised) {
@@ -709,9 +712,11 @@ static char *getpasswd(struct console *con)
                                continue;
                        }
                        ret = NULL;
+
                        switch (errno) {
                        case EIO:
                                con->flags |= CON_EIO;
+                               /* fallthrough */
                        default:
                                warn(_("cannot read %s"), con->tty);
                                break;