Skip to content

Commit

Permalink
Merge pull request torvalds#596 from ojeda/no-ifdef-in-c-file
Browse files Browse the repository at this point in the history
`vsprintf`: avoid `#ifdef` in `.c` file
  • Loading branch information
ojeda authored Dec 14, 2021
2 parents a0f5988 + 3e7c98c commit 911affa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions include/linux/rust.h
Original file line number Diff line number Diff line change
@@ -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 */
7 changes: 1 addition & 6 deletions lib/vsprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <linux/siphash.h>
#include <linux/compiler.h>
#include <linux/property.h>
#include <linux/rust.h>
#ifdef CONFIG_BLOCK
#include <linux/blkdev.h>
#endif
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 911affa

Please sign in to comment.