diff options
author | Bjoern A. Zeeb <bz@FreeBSD.org> | 2024-08-27 21:12:08 +0000 |
---|---|---|
committer | Bjoern A. Zeeb <bz@FreeBSD.org> | 2024-08-31 21:36:01 +0000 |
commit | 1847e63d63f440cfcb2f4ee2c2ee8990f0272d88 (patch) | |
tree | 6690b5370f958324a0a46495032b703682577f4b | |
parent | 273cf7d36336eeed5fc2ad42e5e12a36e36650a0 (diff) |
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
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D46463
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/printk.h | 7 |
1 files changed, 7 insertions, 0 deletions
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_ */ |