Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Add a few static asserts in t_ptrace_wait...



details:   https://anonhg.NetBSD.org/src/rev/edc0d3662240
branches:  trunk
changeset: 459925:edc0d3662240
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue Oct 01 21:13:30 2019 +0000

description:
Add a few static asserts in t_ptrace_wait.c for conditions that must be kept

Assert that ptrace_state and siginfo_t's _ptrace_state are synchronized.

diffstat:

 tests/lib/libc/sys/t_ptrace_wait.c |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (47 lines):

diff -r 88e79dc95829 -r edc0d3662240 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c        Tue Oct 01 18:44:24 2019 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c        Tue Oct 01 21:13:30 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.c,v 1.131 2019/07/01 02:04:37 kamil Exp $        */
+/*     $NetBSD: t_ptrace_wait.c,v 1.132 2019/10/01 21:13:30 kamil Exp $        */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.131 2019/07/01 02:04:37 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.132 2019/10/01 21:13:30 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -41,6 +41,7 @@
 #include <sys/uio.h>
 #include <sys/wait.h>
 #include <machine/reg.h>
+#include <assert.h>
 #include <elf.h>
 #include <err.h>
 #include <errno.h>
@@ -73,6 +74,20 @@
 
 #include <atf-c.h>
 
+/* Assumptions in the kernel code that must be kept. */
+static_assert(sizeof(((struct ptrace_state *)0)->pe_report_event) ==
+    sizeof(((siginfo_t *)0)->si_pe_report_event),
+    "pe_report_event and si_pe_report_event must be of the same size");
+static_assert(sizeof(((struct ptrace_state *)0)->pe_other_pid) ==
+    sizeof(((siginfo_t *)0)->si_pe_other_pid),
+    "pe_other_pid and si_pe_other_pid must be of the same size");
+static_assert(sizeof(((struct ptrace_state *)0)->pe_lwp) ==
+    sizeof(((siginfo_t *)0)->si_pe_lwp),
+    "pe_lwp and si_pe_lwp must be of the same size");
+static_assert(sizeof(((struct ptrace_state *)0)->pe_other_pid) ==
+    sizeof(((struct ptrace_state *)0)->pe_lwp),
+    "pe_other_pid and pe_lwp must be of the same size");
+
 #include "h_macros.h"
 
 #include "t_ptrace_wait.h"



Home | Main Index | Thread Index | Old Index