On Sat, May 17, 2025 at 05:57:40PM +0530, Sameeksha Sankpal wrote: > Signed-off-by: Sameeksha Sankpal <sameekshasank...@gmail.com> > --- > tools/testing/selftests/seccomp/seccomp_bpf.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c > b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 14ba51b52095..d6a85d7b26da 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -4508,7 +4508,11 @@ static char get_proc_stat(struct __test_metadata > *_metadata, pid_t pid) > > snprintf(proc_path, sizeof(proc_path), "/proc/%d/stat", pid); > ASSERT_EQ(get_nth(_metadata, proc_path, 3, &line), 1); > - > + int rc = get_nth(_metadata, proc_path, 3, &line); > + if (rc != 1) { > + printf("[ERROR] user_notification_fifo: failed to read stat for > PID %d (rc=%d)\n", pid, rc); > + } > + ASSERT_EQ(rc, 1);
An ASSERT will stop execution, so if it fails, you'll never reach the printf. And a "printf" shouldn't be used. What you want to use is TH_LOG, probably like this: rc = get_nth(_metadata, proc_path, 3, &line); ASSERT_EQ(rc, 1) { TH_LOG("user_notification_fifo: failed to read stat for PID %d (rc=%d)", pid, rc); } And please don't introduce new variables in the middle -- they need to be declared at the top of the function. -Kees -- Kees Cook