git: 7a3210f2ac09 - main - reboot: convert flags to bools
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 12 Feb 2024 18:53:37 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=7a3210f2ac09c36f46314a98942a29765e99d848 commit 7a3210f2ac09c36f46314a98942a29765e99d848 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-02-12 18:44:52 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-02-12 18:44:52 +0000 reboot: convert flags to bools Convert all the command line flags to bools, since that's how we use them. Sort the includes while adding stdbool.h. Sponsored by: Netflix Reviewed by: kevans, kib, emaste Differential Revision: https://reviews.freebsd.org/D43801 --- sbin/reboot/reboot.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 90c67caf9d07..7dcebef69b85 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -35,38 +35,40 @@ #include <sys/sysctl.h> #include <sys/time.h> -#include <signal.h> #include <err.h> #include <errno.h> #include <fcntl.h> #include <pwd.h> -#include <syslog.h> +#include <signal.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <syslog.h> #include <unistd.h> #include <utmpx.h> static void usage(void) __dead2; static uint64_t get_pageins(void); -static int dohalt; +static bool dohalt; int main(int argc, char *argv[]) { struct utmpx utx; const struct passwd *pw; - int ch, howto, i, fd, lflag, nflag, qflag, sverrno, Nflag; + int ch, howto, i, fd, sverrno; + bool lflag, nflag, qflag, Nflag; uint64_t pageins; const char *user, *kernel = NULL; if (strstr(getprogname(), "halt") != NULL) { - dohalt = 1; + dohalt = true; howto = RB_HALT; } else howto = 0; - lflag = nflag = qflag = Nflag = 0; + lflag = nflag = qflag = Nflag = false; while ((ch = getopt(argc, argv, "cdk:lNnpqr")) != -1) switch(ch) { case 'c': @@ -79,21 +81,21 @@ main(int argc, char *argv[]) kernel = optarg; break; case 'l': - lflag = 1; + lflag = true; break; case 'n': - nflag = 1; + nflag = true; howto |= RB_NOSYNC; break; case 'N': - nflag = 1; - Nflag = 1; + nflag = true; + Nflag = true; break; case 'p': howto |= RB_POWEROFF; break; case 'q': - qflag = 1; + qflag = true; break; case 'r': howto |= RB_REROOT;