The branch stable/12 has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c586a84d56f37eee73d880172ec7f2a8152e58ab

commit c586a84d56f37eee73d880172ec7f2a8152e58ab
Author:     Ed Maste <[email protected]>
AuthorDate: 2021-01-11 00:02:55 +0000
Commit:     Ed Maste <[email protected]>
CommitDate: 2021-01-15 14:25:36 +0000

    cmp: use C99 bool for flags
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D28072
    
    (cherry picked from commit 1f7661742de650bcb6b9124ee3da7e94c8650c4b)
---
 usr.bin/cmp/cmp.c    | 27 ++++++++++++++-------------
 usr.bin/cmp/extern.h |  2 +-
 usr.bin/cmp/link.c   |  1 +
 usr.bin/cmp/misc.c   |  1 +
 4 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c
index e1f9fb6823ef..c762f1346abf 100644
--- a/usr.bin/cmp/cmp.c
+++ b/usr.bin/cmp/cmp.c
@@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$");
 
 #include "extern.h"
 
-int    lflag, sflag, xflag, zflag;
+bool   lflag, sflag, xflag, zflag;
 
 static const struct option long_opts[] =
 {
@@ -77,7 +77,8 @@ main(int argc, char *argv[])
 {
        struct stat sb1, sb2;
        off_t skip1, skip2;
-       int ch, fd1, fd2, oflag, special;
+       int ch, fd1, fd2, oflag;
+       bool special;
        const char *file1, *file2;
 
        oflag = O_RDONLY;
@@ -87,18 +88,18 @@ main(int argc, char *argv[])
                        oflag |= O_NOFOLLOW;
                        break;
                case 'l':               /* print all differences */
-                       lflag = 1;
+                       lflag = true;
                        break;
                case 's':               /* silent run */
-                       sflag = 1;
-                       zflag = 1;
+                       sflag = true;
+                       zflag = true;
                        break;
                case 'x':               /* hex output */
-                       lflag = 1;
-                       xflag = 1;
+                       lflag = true;
+                       xflag = true;
                        break;
                case 'z':               /* compare size first */
-                       zflag = 1;
+                       zflag = true;
                        break;
                case '?':
                default:
@@ -120,9 +121,9 @@ main(int argc, char *argv[])
                err(ERR_EXIT, "unable to limit rights on stderr");
 
        /* Backward compatibility -- handle "-" meaning stdin. */
-       special = 0;
+       special = false;
        if (strcmp(file1 = argv[0], "-") == 0) {
-               special = 1;
+               special = true;
                fd1 = STDIN_FILENO;
                file1 = "stdin";
        } else if ((fd1 = open(file1, oflag, 0)) < 0 && errno != EMLINK) {
@@ -135,7 +136,7 @@ main(int argc, char *argv[])
                if (special)
                        errx(ERR_EXIT,
                                "standard input may only be specified once");
-               special = 1;
+               special = true;
                fd2 = STDIN_FILENO;
                file2 = "stdin";
        } else if ((fd2 = open(file2, oflag, 0)) < 0 && errno != EMLINK) {
@@ -174,7 +175,7 @@ main(int argc, char *argv[])
                                exit(ERR_EXIT);
                }
                if (!S_ISREG(sb1.st_mode))
-                       special = 1;
+                       special = true;
                else {
                        if (fstat(fd2, &sb2)) {
                                if (!sflag)
@@ -183,7 +184,7 @@ main(int argc, char *argv[])
                                        exit(ERR_EXIT);
                        }
                        if (!S_ISREG(sb2.st_mode))
-                               special = 1;
+                               special = true;
                }
        }
 
diff --git a/usr.bin/cmp/extern.h b/usr.bin/cmp/extern.h
index 84507b1929dc..82c5ea42b175 100644
--- a/usr.bin/cmp/extern.h
+++ b/usr.bin/cmp/extern.h
@@ -44,4 +44,4 @@ void  c_special(int, const char *, off_t, int, const char *, 
off_t);
 void   diffmsg(const char *, const char *, off_t, off_t);
 void   eofmsg(const char *);
 
-extern int lflag, sflag, xflag, zflag;
+extern bool lflag, sflag, xflag, zflag;
diff --git a/usr.bin/cmp/link.c b/usr.bin/cmp/link.c
index 3aecf4f10738..9193147e830e 100644
--- a/usr.bin/cmp/link.c
+++ b/usr.bin/cmp/link.c
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/types.h>
 #include <err.h>
 #include <limits.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/usr.bin/cmp/misc.c b/usr.bin/cmp/misc.c
index a99ab4facb73..1e84f0d7a527 100644
--- a/usr.bin/cmp/misc.c
+++ b/usr.bin/cmp/misc.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/types.h>
 
 #include <err.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to