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)
This commit is contained in:
Bjoern A. Zeeb 2024-08-27 21:12:08 +00:00
parent 6dedd620cf
commit cedae002cb

View file

@ -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_ */