git: b3734c1386dd - main - tests/sys/kern/procdesc.c: mark grandchild var in pdopenpid_capmode() as volatile

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 01 Sep 2026 13:56:58 UTC
The branch main has been updated by kib:

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

commit b3734c1386dd2b0ade1a7f20d9ebf5f62c01819e
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-08-30 23:46:27 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-09-01 13:56:34 +0000

    tests/sys/kern/procdesc.c: mark grandchild var in pdopenpid_capmode() as volatile
    
    The variable is written in the child process which shares the address
    space with the parent.  The data flow must not be optimized by a compiler.
    
    Reviewed by:    markj
    Fixes:  ddf62c83fc0a ("sys/tests/kern/pdopenpid: pdopenpid(2) is allowed in cap mode")
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D59282
---
 tests/sys/kern/procdesc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/sys/kern/procdesc.c b/tests/sys/kern/procdesc.c
index 862b8277913f..d6f19548bd05 100644
--- a/tests/sys/kern/procdesc.c
+++ b/tests/sys/kern/procdesc.c
@@ -372,7 +372,8 @@ ATF_TC_BODY(pdopenpid_child, tc)
 ATF_TC_WITHOUT_HEAD(pdopenpid_capmode);
 ATF_TC_BODY(pdopenpid_capmode, tc)
 {
-	pid_t child, grandchild;
+	pid_t child;
+	volatile pid_t grandchild;
 
 	ATF_REQUIRE_FEATURE("security_capability_mode");