Skip to content

Commit 1c17d77

Browse files
authored
Merge pull request #715 from ojeda/petr
printk/vsprintf: C side printing rework
2 parents 715f398 + 05e2c2f commit 1c17d77

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16821,7 +16821,6 @@ T: git https://github.com/Rust-for-Linux/linux.git rust-next
1682116821
F: rust/
1682216822
F: samples/rust/
1682316823
F: Documentation/rust/
16824-
F: lib/rust.h
1682516824
F: scripts/*rust*
1682616825
K: \b(?i:rust)\b
1682716826

kernel/printk/printk.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,7 @@ static struct latched_seq clear_seq = {
392392
/* the maximum size of a formatted record (i.e. with prefix added per line) */
393393
#define CONSOLE_LOG_MAX 1024
394394

395-
/*
396-
* The maximum size allowed to be reserved for a record.
397-
* Keep in sync with rust/kernel/print.rs.
398-
*/
395+
/* the maximum size allowed to be reserved for a record */
399396
#define LOG_LINE_MAX (CONSOLE_LOG_MAX - PREFIX_MAX)
400397

401398
#define LOG_LEVEL(v) ((v) & 0x07)

lib/rust.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

lib/vsprintf.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
#include <linux/string_helpers.h>
5454
#include "kstrtox.h"
55-
#include "rust.h"
5655

5756
static noinline unsigned long long simple_strntoull(const char *startp, size_t max_chars, char **endp, unsigned int base)
5857
{
@@ -2253,6 +2252,9 @@ int __init no_hash_pointers_enable(char *str)
22532252
}
22542253
early_param("no_hash_pointers", no_hash_pointers_enable);
22552254

2255+
/* Used for Rust formatting ('%pA'). */
2256+
char *rust_fmt_argument(char* buf, char* end, void *ptr);
2257+
22562258
/*
22572259
* Show a '%p' thing. A kernel extension is that the '%p' is followed
22582260
* by an extra set of alphanumeric characters that are extended format
@@ -2456,6 +2458,10 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
24562458
case 'f':
24572459
return fwnode_string(buf, end, ptr, spec, fmt + 1);
24582460
case 'A':
2461+
if (!IS_ENABLED(CONFIG_RUST)) {
2462+
WARN_ONCE(1, "Please remove %%pA from non-Rust code\n");
2463+
return error_string(buf, end, "(%pA?)", spec);
2464+
}
24592465
return rust_fmt_argument(buf, end, ptr);
24602466
case 'x':
24612467
return pointer_string(buf, end, ptr, spec);

0 commit comments

Comments
 (0)