git: 0c62a06b84ab - stable/14 - kassert.h: update MPASS definition commentary
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 18 Apr 2024 18:19:04 UTC
The branch stable/14 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=0c62a06b84abde27e170d783b1c8cce3402831ca commit 0c62a06b84abde27e170d783b1c8cce3402831ca Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2024-03-21 15:21:41 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2024-04-18 18:17:52 +0000 kassert.h: update MPASS definition commentary We now have a detailed man page describing both MPASS and KASSERT. Give a warning that careless use of MPASS can result in inadequate assertion messages, and point to the MPASS(9) page which describes this. While here add a comment above the KASSERT definitions pointing to the man page. Suggested by: bz Reviewed by: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D44438 (cherry picked from commit 36de8bb226671ef9fe373d8d95f77cdb76157738) --- sys/sys/kassert.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/sys/kassert.h b/sys/sys/kassert.h index da7b66854a14..8e22e0e2c9f9 100644 --- a/sys/sys/kassert.h +++ b/sys/sys/kassert.h @@ -112,6 +112,9 @@ void kassert_panic(const char *fmt, ...) __printflike(1, 2); # endif /* defined(WITNESS) || defined(INVARIANT_SUPPORT) */ #endif /* _STANDALONE */ +/* + * Kernel assertion; see KASSERT(9) for details. + */ #if (defined(_KERNEL) && defined(INVARIANTS)) || defined(_STANDALONE) #define KASSERT(exp,msg) do { \ if (__predict_false(!(exp))) \ @@ -124,8 +127,11 @@ void kassert_panic(const char *fmt, ...) __printflike(1, 2); #ifdef _KERNEL /* - * Helpful macros for quickly coming up with assertions with informative - * panic messages. + * Macros for generating panic messages based on the exact condition text. + * + * NOTE: Use these with care, as the resulting message might omit key + * information required to understand the assertion failure. Consult the + * MPASS(9) man page for guidance. */ #define MPASS(ex) MPASS4(ex, #ex, __FILE__, __LINE__) #define MPASS2(ex, what) MPASS4(ex, what, __FILE__, __LINE__)