git: cedae002cba4 - stable/14 - LinuxKPI: add no_printk

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sat, 28 Sep 2024 10:38:22 UTC
The branch stable/14 has been updated by bz:

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

commit cedae002cba47fbeb5e0de2393eb3a4673590019
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-08-27 21:12:08 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-09-28 10:35:14 +0000

    LinuxKPI: add no_printk
    
    Add a version of no_printk(), which seems to be there to have format
    string checking while never calling the printk.  It seems a very weird
    thing and it needs a return code and for some reason my initial
    while (0) { } version hadn't worked while porting over new code but
    could have been further downstream format string problems.
    if (0) seems to do the job though I would have expected that to more
    likely simply get optimised out without any futher format checking.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    emaste
    Differential Revision: https://reviews.freebsd.org/D46463
    
    (cherry picked from commit 1847e63d63f440cfcb2f4ee2c2ee8990f0272d88)
---
 sys/compat/linuxkpi/common/include/linux/printk.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/printk.h b/sys/compat/linuxkpi/common/include/linux/printk.h
index 933d5aa6f94a..3840a6e5fb8a 100644
--- a/sys/compat/linuxkpi/common/include/linux/printk.h
+++ b/sys/compat/linuxkpi/common/include/linux/printk.h
@@ -125,4 +125,11 @@ print_hex_dump_bytes(const char *prefix_str, const int prefix_type,
 #define	pr_info_ratelimited(fmt, ...) \
 	printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
 
+#define	no_printk(fmt, ...)					\
+({								\
+	if (0)							\
+		printk(pr_fmt(fmt), ##__VA_ARGS__);		\
+	0;							\
+})
+
 #endif					/* _LINUXKPI_LINUX_PRINTK_H_ */