]> granicus.if.org Git - shadow/commitdiff
* src/logoutd.c: Use a bool when possible instead of int integers.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 9 Jun 2008 20:02:46 +0000 (20:02 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 9 Jun 2008 20:02:46 +0000 (20:02 +0000)
* src/logoutd.c: Avoid implicit conversion of pointers / integers
/ chars to booleans.
* src/logoutd.c: Ignore return value of setlocale(),
bindtextdomain(), and textdomain().
* src/logoutd.c: Add brackets and parenthesis.

ChangeLog
src/logoutd.c

index 71a0244007c0ec58abba6a31a3efbd6bcde5c890..691f2431cedb4b618ca32280252b00bdf5649f02 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-06-09  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * src/logoutd.c: Use a bool when possible instead of int integers.
+       * src/logoutd.c: Avoid implicit conversion of pointers / integers
+       / chars to booleans.
+       * src/logoutd.c: Ignore return value of setlocale(),
+       bindtextdomain(), and textdomain().
+       * src/logoutd.c: Add brackets and parenthesis.
+
 2008-06-09  Nicolas François  <nicolas.francois@centraliens.net>
 
        * src/chpasswd.c: Use a bool when possible instead of int
index 9147e7b455684d50bc947473823cf5b5a7361de7..e00af4b66daa874e0de919286a22ffa01a3506ce 100644 (file)
@@ -82,8 +82,9 @@ static int check_login (const struct utmp *ut)
        /*
         * Check if they are allowed to be logged in right now.
         */
-       if (!isttytime (user, ut->ut_line, now))
+       if (!isttytime (user, ut->ut_line, now)) {
                return 0;
+       }
        return 1;
 }
 
@@ -92,11 +93,13 @@ static void send_mesg_to_tty (int tty_fd)
 {
        TERMIO oldt, newt;
        FILE *mesg_file, *tty_file;
-       int c, is_tty;
+       int c;
+       bool is_tty;
 
        tty_file = fdopen (tty_fd, "w");
-       if (!tty_file)
+       if (NULL == tty_file) {
                return;
+       }
 
        is_tty = (GTTY (tty_fd, &oldt) == 0);
        if (is_tty) {
@@ -108,10 +111,11 @@ static void send_mesg_to_tty (int tty_fd)
        }
 
        mesg_file = fopen (HUP_MESG_FILE, "r");
-       if (mesg_file) {
+       if (NULL != mesg_file) {
                while ((c = getc (mesg_file)) != EOF) {
-                       if (c == '\n')
+                       if (c == '\n') {
                                putc ('\r', tty_file);
+                       }
                        putc (c, tty_file);
                }
                fclose (mesg_file);
@@ -150,9 +154,9 @@ int main (int argc, char **argv)
        char tty_name[sizeof (ut->ut_line) + 6];        /* /dev/ + NUL */
        int tty_fd;
 
-       setlocale (LC_ALL, "");
-       bindtextdomain (PACKAGE, LOCALEDIR);
-       textdomain (PACKAGE);
+       (void) setlocale (LC_ALL, "");
+       (void) bindtextdomain (PACKAGE, LOCALEDIR);
+       (void) textdomain (PACKAGE);
 
 #ifndef DEBUG
        for (i = 0; close (i) == 0; i++);
@@ -184,7 +188,7 @@ int main (int argc, char **argv)
         * Scan the utmpx/utmp file once per minute looking for users that
         * are not supposed to still be logged in.
         */
-       while (1) {
+       while (true) {
 
                /* 
                 * Attempt to re-open the utmpx/utmp file. The file is only
@@ -202,16 +206,19 @@ int main (int argc, char **argv)
                 * is permitted to be signed on at this time.
                 */
 #if HAVE_UTMPX_H
-               while ((ut = getutxent ())) {
+               while ((ut = getutxent ()) != NULL) {
 #else
-               while ((ut = getutent ())) {
+               while ((ut = getutent ()) != NULL) {
 #endif
-                       if (ut->ut_type != USER_PROCESS)
+                       if (ut->ut_type != USER_PROCESS) {
                                continue;
-                       if (ut->ut_user[0] == '\0')
+                       }
+                       if (ut->ut_user[0] == '\0') {
                                continue;
-                       if (check_login (ut))
+                       }
+                       if (check_login (ut)) {
                                continue;
+                       }
 
                        /*
                         * Put the rest of this in a child process. This
@@ -228,10 +235,11 @@ int main (int argc, char **argv)
                        }
                        /* child */
 
-                       if (strncmp (ut->ut_line, "/dev/", 5) != 0)
+                       if (strncmp (ut->ut_line, "/dev/", 5) != 0) {
                                strcpy (tty_name, "/dev/");
-                       else
+                       } else {
                                tty_name[0] = '\0';
+                       }
 
                        strcat (tty_name, ut->ut_line);
 #ifndef O_NOCTTY
@@ -281,3 +289,4 @@ int main (int argc, char **argv)
        return 1;
        /* NOT REACHED */
 }
+