From 3e7c98c0eeefd392badeb4ff0773fcf150b6d63b Mon Sep 17 00:00:00 2001 From: Miguel Ojeda Date: Tue, 14 Dec 2021 19:28:27 +0100 Subject: [PATCH] `vsprintf`: avoid `#ifdef` in `.c` file Suggested-by: Greg Kroah-Hartman Signed-off-by: Miguel Ojeda --- MAINTAINERS | 1 + include/linux/rust.h | 14 ++++++++++++++ lib/vsprintf.c | 7 +------ 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 include/linux/rust.h diff --git a/MAINTAINERS b/MAINTAINERS index 2683d788d0604f..e0f1dfaa770093 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16574,6 +16574,7 @@ T: git https://github.com/Rust-for-Linux/linux.git rust-next F: rust/ F: samples/rust/ F: Documentation/rust/ +F: include/linux/rust.h K: \b(?i:rust)\b RXRPC SOCKETS (AF_RXRPC) diff --git a/include/linux/rust.h b/include/linux/rust.h new file mode 100644 index 00000000000000..70626e5a4f87cf --- /dev/null +++ b/include/linux/rust.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_RUST_H +#define __LINUX_RUST_H + +#ifdef CONFIG_RUST +char *rust_fmt_argument(char* buf, char* end, void *ptr); +#else +static inline char *rust_fmt_argument(char* buf, char* end, void *ptr) +{ + return NULL; +} +#endif + +#endif /* __LINUX_RUST_H */ diff --git a/lib/vsprintf.c b/lib/vsprintf.c index bc9c05427d9ae6..f046e11fc7039e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -41,6 +41,7 @@ #include #include #include +#include #ifdef CONFIG_BLOCK #include #endif @@ -2233,10 +2234,6 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode, return widen_string(buf, buf - buf_start, end, spec); } -#ifdef CONFIG_RUST -char *rust_fmt_argument(char* buf, char* end, void *ptr); -#endif - /* Disable pointer hashing if requested */ bool no_hash_pointers __ro_after_init; EXPORT_SYMBOL_GPL(no_hash_pointers); @@ -2468,10 +2465,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, return device_node_string(buf, end, ptr, spec, fmt + 1); case 'f': return fwnode_string(buf, end, ptr, spec, fmt + 1); -#ifdef CONFIG_RUST case 'A': return rust_fmt_argument(buf, end, ptr); -#endif case 'x': return pointer_string(buf, end, ptr, spec); case 'e':