Module Name:    src
Committed By:   riastradh
Date:           Mon Nov 27 22:18:29 UTC 2023

Modified Files:
        src/tests/lib/libpthread: t_stack.c

Log Message:
libpthread/t_stack: Appease gcc12 maybe-uninitialized warning.

The jmp_buf is not, in fact, uninitialized at the point of use, but
it doesn't hurt to narrow the scope a bit to between when the jmp_buf
is initialized by setjmp, and when the signal handler might be called
after sigaction.

Noted by prlw1.

PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libpthread/t_stack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libpthread/t_stack.c
diff -u src/tests/lib/libpthread/t_stack.c:1.3 src/tests/lib/libpthread/t_stack.c:1.4
--- src/tests/lib/libpthread/t_stack.c:1.3	Mon Nov 27 22:17:41 2023
+++ src/tests/lib/libpthread/t_stack.c	Mon Nov 27 22:18:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_stack.c,v 1.3 2023/11/27 22:17:41 riastradh Exp $	*/
+/*	$NetBSD: t_stack.c,v 1.4 2023/11/27 22:18:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #define	_KMEMUSER		/* __MACHINE_STACK_GROWS_UP */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_stack.c,v 1.3 2023/11/27 22:17:41 riastradh Exp $");
+__RCSID("$NetBSD: t_stack.c,v 1.4 2023/11/27 22:18:29 riastradh Exp $");
 
 #include <sys/mman.h>
 #include <sys/param.h>
@@ -216,8 +216,8 @@ checksigsegv(const char *p)
 	memset(&act, 0, sizeof(act));
 	act.sa_handler = &sigsegv_ok;
 
-	pthread_setspecific(C->jmp_key, &j);
 	if (setjmp(j.buf) == 0) {
+		pthread_setspecific(C->jmp_key, &j);
 		RL(sigaction(SIGSEGV, &act, &oact));
 		oactsave = oact;
 		v = *p;		/* trigger SIGSEGV */
@@ -249,8 +249,8 @@ checknosigsegv(const char *p)
 	memset(&act, 0, sizeof(act));
 	act.sa_handler = &sigsegv_ok;
 
-	pthread_setspecific(C->jmp_key, &j);
 	if (setjmp(j.buf) == 0) {
+		pthread_setspecific(C->jmp_key, &j);
 		RL(sigaction(SIGSEGV, &act, &oact));
 		oactsave = oact;
 		v = *p;		/* better not trigger SIGSEGV */

Reply via email to