]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/port.c: getportent(): Remove obvious comments
authorAlejandro Colomar <alx@kernel.org>
Tue, 2 Jul 2024 12:26:19 +0000 (14:26 +0200)
committerSerge Hallyn <serge@hallyn.com>
Sat, 6 Jul 2024 12:44:02 +0000 (07:44 -0500)
And do some style changes on the corresponding code.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/port.c

index 7348030e57b8f0ea7a0f09f5be8aade3b4dcca04..f55bc724c7f69dbbe7722a33f1a1199d8df411b8 100644 (file)
@@ -131,19 +131,14 @@ static struct port *getportent (void)
         */
 
 next:
-
-       /*
-        * Get the next line and remove optional trailing '\n'.
-        * Lines which begin with '#' are all ignored.
-        */
-
-       if (fgets (buf, sizeof buf, ports) == 0) {
+       if (fgets(buf, sizeof(buf), ports) == NULL) {
                errno = saveerr;
-               return 0;
+               return NULL;
        }
-       if ('#' == buf[0]) {
+       if ('#' == buf[0])
                goto next;
-       }
+
+       stpcpy(strchrnul(buf, '\n'), "");
 
        /*
         * Get the name of the TTY device.  It is the first colon
@@ -152,8 +147,6 @@ next:
         * TTY devices.
         */
 
-       stpcpy(strchrnul(buf, '\n'), "");
-
        port.pt_names = ttys;
        for (cp = buf, j = 0; j < PORT_TTY; j++) {
                port.pt_names[j] = cp;