git: bc43a9a7157a - main - daemon: change type of listen_child() to C99 bool

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Fri, 03 Mar 2023 05:17:24 UTC
The branch main has been updated by kevans:

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

commit bc43a9a7157a8249a492ee3efd8589369dd94228
Author:     Ihor Antonov <ihor@antonovs.family>
AuthorDate: 2023-03-03 05:17:02 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-03-03 05:17:02 +0000

    daemon: change type of listen_child() to C99 bool
    
    Reviewed by:    kevans
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/672
---
 usr.sbin/daemon/daemon.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c
index 964a77deb0f9..5c636bcd0a03 100644
--- a/usr.sbin/daemon/daemon.c
+++ b/usr.sbin/daemon/daemon.c
@@ -73,9 +73,9 @@ static void restrict_process(const char *);
 static void handle_term(int);
 static void handle_chld(int);
 static void handle_hup(int);
-static int open_log(const char *);
+static int  open_log(const char *);
 static void reopen_log(struct log_params *);
-static int  listen_child(int, struct log_params *);
+static bool listen_child(int, struct log_params *);
 static int  get_log_mapping(const char *, const CODE *);
 static void open_pid_files(const char *, const char *, struct pidfh **,
 			   struct pidfh **);
@@ -146,13 +146,13 @@ main(int argc, char *argv[])
 {
 	bool supervision_enabled = false;
 	bool log_reopen = false;
+	bool child_eof = false;
 	char *p = NULL;
 	const char *child_pidfile = NULL;
 	const char *parent_pidfile = NULL;
 	const char *title = NULL;
 	const char *user = NULL;
 	int ch = 0;
-	int child_eof = 0;
 	int keep_cur_workdir = 1;
 	int pfd[2] = { -1, -1 };
 	int restart = 0;
@@ -580,10 +580,10 @@ restrict_process(const char *user)
  * We try to collect whole lines terminated by '\n'. Otherwise we collect a
  * full buffer, and then output it.
  *
- * Return value of 0 is assumed to mean EOF or error, and 1 indicates to
+ * Return value of false is assumed to mean EOF or error, and true indicates to
  * continue reading.
  */
-static int
+static bool
 listen_child(int fd, struct log_params *logpar)
 {
 	static unsigned char buf[LBUF_SIZE];
@@ -617,18 +617,18 @@ listen_child(int fd, struct log_params *logpar)
 		}
 		/* Wait until the buffer is full. */
 		if (bytes_read < LBUF_SIZE - 1) {
-			return 1;
+			return true;
 		}
 		do_output(buf, bytes_read, logpar);
 		bytes_read = 0;
-		return 1;
+		return true;
 	} else if (rv == -1) {
 		/* EINTR should trigger another read. */
 		if (errno == EINTR) {
-			return 1;
+			return true;
 		} else {
 			warn("read");
-			return 0;
+			return false;
 		}
 	}
 	/* Upon EOF, we have to flush what's left of the buffer. */
@@ -636,7 +636,7 @@ listen_child(int fd, struct log_params *logpar)
 		do_output(buf, bytes_read, logpar);
 		bytes_read = 0;
 	}
-	return 0;
+	return false;
 }
 
 /*