git: 6b0cf2a2379b - main - vfs_lookup.c: only call ktrcapfail() if KTRACE is enabled

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 24 Apr 2024 19:43:44 UTC
The branch main has been updated by kib:

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

commit 6b0cf2a2379b86b67269ed4549057cd6d69490e5
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-04-24 19:06:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-04-24 19:43:32 +0000

    vfs_lookup.c: only call ktrcapfail() if KTRACE is enabled
    
    Reviewed by:    emaste, imp, markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D44931
---
 sys/kern/vfs_lookup.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 180605f9eb8a..290834c10be5 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -86,8 +86,14 @@ static void NDVALIDATE_impl(struct nameidata *, int);
 	ndp->ni_cnd.cn_flags |= ISRESTARTED;				\
 } while (0)
 
+#ifdef KTRACE
+#define	NIKTRCAPFAIL(path)	ktrcapfail(CAPFAIL_NAMEI, (path))
+#else
+#define	NIKTRCAPFAIL(path)
+#endif
+
 #define	NI_CAP_VIOLATION(ndp, path)	do {			\
-	ktrcapfail(CAPFAIL_NAMEI, (path));			\
+	NIKTRCAPFAIL(path);					\
 	(ndp)->ni_lcf &= ~NI_LCF_KTR_FLAGS;			\
 } while (0)