Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Mar 2023 03:01:03 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 259ed21d21f8 - main - daemon: initialize struct sigaction at declaration site
Message-ID:  <202303020301.322313Mr034059@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kevans:

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

commit 259ed21d21f81b656f06447716d41c190576477e
Author:     Ihor Antonov <ihor@antonovs.family>
AuthorDate: 2023-03-02 03:00:42 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-03-02 03:00:42 +0000

    daemon: initialize struct sigaction at declaration site
    
    This improves readability by uncluttering the code
    
    Reviewed by:    kevans
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/669
---
 usr.sbin/daemon/daemon.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c
index 4fe749d9e5fa..0925d16a27a0 100644
--- a/usr.sbin/daemon/daemon.c
+++ b/usr.sbin/daemon/daemon.c
@@ -287,20 +287,19 @@ main(int argc, char *argv[])
 	 * and syslog.
 	 */
 	if (pidfile || ppidfile || restart || outfd != -1 || dosyslog) {
-		struct sigaction act_term, act_chld, act_hup;
+		struct sigaction act_term = { 0 };
+		struct sigaction act_chld = { 0 };
+		struct sigaction act_hup = { 0 };
 
 		/* Avoid PID racing with SIGCHLD and SIGTERM. */
-		memset(&act_term, 0, sizeof(act_term));
 		act_term.sa_handler = handle_term;
 		sigemptyset(&act_term.sa_mask);
 		sigaddset(&act_term.sa_mask, SIGCHLD);
 
-		memset(&act_chld, 0, sizeof(act_chld));
 		act_chld.sa_handler = handle_chld;
 		sigemptyset(&act_chld.sa_mask);
 		sigaddset(&act_chld.sa_mask, SIGTERM);
 
-		memset(&act_hup, 0, sizeof(act_hup));
 		act_hup.sa_handler = handle_hup;
 		sigemptyset(&act_hup.sa_mask);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303020301.322313Mr034059>