Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 1/5] progress.c: replace signal() with sigaction()

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:01:24

David Kastrup [off-list ref] writes:
quoted
quoted
diff --git a/progress.c b/progress.c
index 261314e..24df263 100644
--- a/progress.c
+++ b/progress.c
@@ -66,8 +66,12 @@ static void set_progress_signal(void)
 static void clear_progress_signal(void)
 {
 	struct itimerval v = {{0,},};
+	struct sigaction sa;
+
+	memset(&sa, 0, sizeof(sa));
+	sa.sa_handler = SIG_IGN;
A C99 initialiser here would save the call to memset. Unfortunately
Documentation/CodingGuidelines is fairly clear on not using C99
initialisers, given the fact we're now at git 2.0 maybe it's time to
revisit this policy?
If I look at the initialization of v in the context immediately above
the new code, it would appear that somebody already revisited this
policy.
The existing structure initialization that says "the first field of
the structure is set to 0" implying "everything else will also be
set to 0" is not what we avoid.  That is straight C89.

What we avoid is an initializer with a designator, e.g.

	struct sigaction sa = {
        	.sa_handler = NULL,
                .sa_flags = 0,
	};
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help