diff options
author | Ihor Antonov <ihor@antonovs.family> | 2023-03-02 03:00:42 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2023-03-02 03:00:42 +0000 |
commit | f2f9d31d9f9f7f319edb95874b41af0733a26624 (patch) | |
tree | 5c2fe13c4efb6d600d64ee3cece806b5064f24ff | |
parent | 203df05b692b5e2b92c990d8971f5797e3a7a139 (diff) | |
download | src-f2f9d31d9f9f7f319edb95874b41af0733a26624.tar.gz src-f2f9d31d9f9f7f319edb95874b41af0733a26624.zip |
daemon: make dosyslog variable a bool and give it a better name
Following style(9) and C99 recommendation use bool instead of
int for boolean operations. Also give the variable a more descriptive
name that follows boolean naming convention.
Reviewed by: kevans
Pull Request: https://github.com/freebsd/freebsd-src/pull/669
-rw-r--r-- | usr.sbin/daemon/daemon.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index f15a3f567a8c..344b914d464b 100644 --- a/usr.sbin/daemon/daemon.c +++ b/usr.sbin/daemon/daemon.c @@ -60,11 +60,11 @@ __FBSDID("$FreeBSD$"); #define LBUF_SIZE 4096 struct log_params { - int dosyslog; int logpri; int noclose; int outfd; const char *outfn; + bool syslog_enabled; }; static void restrict_process(const char *); @@ -143,6 +143,7 @@ int main(int argc, char *argv[]) { bool supervision_enabled = false; + bool syslog_enabled = false; char *p = NULL; const char *pidfile = NULL; const char *logtag = "daemon"; @@ -152,7 +153,6 @@ main(int argc, char *argv[]) const char *user = NULL; int ch = 0; int child_eof = 0; - int dosyslog = 0; int log_reopen = 0; int logfac = LOG_DAEMON; int logpri = LOG_NOTICE; @@ -191,7 +191,7 @@ main(int argc, char *argv[]) if (logfac == -1) { errx(5, "unrecognized syslog facility"); } - dosyslog = 1; + syslog_enabled = true; break; case 'm': stdmask = strtol(optarg, &p, 10); @@ -222,17 +222,17 @@ main(int argc, char *argv[]) if (logpri == -1) { errx(4, "unrecognized syslog priority"); } - dosyslog = 1; + syslog_enabled = true; break; case 'S': - dosyslog = 1; + syslog_enabled = true; break; case 't': title = optarg; break; case 'T': logtag = optarg; - dosyslog = 1; + syslog_enabled = true; break; case 'u': user = optarg; @@ -262,7 +262,7 @@ main(int argc, char *argv[]) } } - if (dosyslog) { + if (syslog_enabled) { openlog(logtag, LOG_PID | LOG_NDELAY, logfac); } @@ -299,7 +299,7 @@ main(int argc, char *argv[]) ppidfile != NULL || restart != 0 || outfd != -1 || - dosyslog != 0; + syslog_enabled == true; if (supervision_enabled) { struct sigaction act_term = { 0 }; @@ -349,7 +349,7 @@ main(int argc, char *argv[]) */ (void)madvise(NULL, 0, MADV_PROTECT); logpar.outfd = outfd; - logpar.dosyslog = dosyslog; + logpar.syslog_enabled = syslog_enabled; logpar.logpri = logpri; logpar.noclose = noclose; logpar.outfn = outfn; @@ -487,7 +487,7 @@ exit: close(outfd); close(pfd[0]); close(pfd[1]); - if (dosyslog) { + if (syslog_enabled) { closelog(); } pidfile_remove(pfh); @@ -647,14 +647,14 @@ do_output(const unsigned char *buf, size_t len, struct log_params *logpar) if (len < 1) { return; } - if (logpar->dosyslog) { + if (logpar->syslog_enabled) { syslog(logpar->logpri, "%.*s", (int)len, buf); } if (logpar->outfd != -1) { if (write(logpar->outfd, buf, len) == -1) warn("write"); } - if (logpar->noclose && !logpar->dosyslog && logpar->outfd == -1) { + if (logpar->noclose && !logpar->syslog_enabled && logpar->outfd == -1) { printf("%.*s", (int)len, buf); } } |