diff options
author | Jake Freeland <jfree@FreeBSD.org> | 2023-09-01 02:50:26 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2023-09-28 15:51:53 +0000 |
commit | bbde787c6668803e2c4e999ef699d545b26160a6 (patch) | |
tree | 0ffef19f992de1ee8abe6343f31863c30acde0c4 | |
parent | fe233250d6fd0d4b915c89244f2b1f79cb45284e (diff) | |
download | src-bbde787c6668803e2c4e999ef699d545b26160a6.tar.gz src-bbde787c6668803e2c4e999ef699d545b26160a6.zip |
syslogd: Merge loops
Merge the two loops that traverse the global filed queue. Both loops'
actions are not dependent on the other, so combining them is safe.
Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41370
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index c20928d48495..a37f3a9482bf 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -2575,7 +2575,10 @@ init(bool reload) * Close all open log files. */ Initialized = false; - STAILQ_FOREACH(f, &fhead, next) { + while (!STAILQ_EMPTY(&fhead)) { + f = STAILQ_FIRST(&fhead); + STAILQ_REMOVE_HEAD(&fhead, next); + /* flush any pending output */ if (f->f_prevcount) fprintlog_successive(f, 0); @@ -2593,10 +2596,7 @@ init(bool reload) default: break; } - } - while(!STAILQ_EMPTY(&fhead)) { - f = STAILQ_FIRST(&fhead); - STAILQ_REMOVE_HEAD(&fhead, next); + free(f->f_program); free(f->f_host); if (f->f_prop_filter) { |