]> granicus.if.org Git - shadow/commitdiff
* is_my_tty returns a bool.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 25 May 2008 21:33:38 +0000 (21:33 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 25 May 2008 21:33:38 +0000 (21:33 +0000)
* Avoid implicit conversion of integers to booleans.
* Add brackets.

ChangeLog
libmisc/chowntty.c

index fc1a09d04241f5f89722cae05066508f79e3cbc2..124d141066bc00effe71f9af365cd83fac9c9544 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-05-25  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * libmisc/chowntty.c: is_my_tty returns a bool.
+       * libmisc/chowntty.c: Avoid implicit conversion of integers to
+       booleans.
+       * libmisc/chowntty.c: Add brackets.
+
 2008-05-25  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/chowndir.c: Avoid assignment in comparisons, implicit
index fcfad917801421d688ff86e0c624a6104d5913d0..9d0e50a5b726fec309756d8d61f5a6eeabd98de5 100644 (file)
 /*
  * is_my_tty -- determine if "tty" is the same as TTY stdin is using
  */
-static int is_my_tty (const char *tty)
+static bool is_my_tty (const char *tty)
 {
        struct stat by_name, by_fd;
 
-       if (stat (tty, &by_name) || fstat (0, &by_fd))
-               return 0;
+       if ((stat (tty, &by_name) != 0) || (fstat (0, &by_fd) != 0)) {
+               return false;
+       }
 
-       if (by_name.st_rdev != by_fd.st_rdev)
-               return 0;
-       else
-               return 1;
+       if (by_name.st_rdev != by_fd.st_rdev) {
+               return false;
+       } else {
+               return true;
+       }
 }
 
 /*
@@ -102,8 +104,8 @@ void chown_tty (const char *tty, const struct passwd *info)
                exit (1);
        }
 
-       if (chown (tty, info->pw_uid, gid) ||
-           chmod (tty, getdef_num ("TTYPERM", 0600))) {
+       if ((chown (tty, info->pw_uid, gid) != 0)||
+           (chmod (tty, getdef_num ("TTYPERM", 0600)) != 0)) {
                int err = errno;
 
                snprintf (buf, sizeof buf, _("Unable to change tty %s"), tty);