Re: [PATCH v4 12/20] vsprintf: add new `%pA` format specifier

From: Miguel Ojeda
Date: Mon Feb 14 2022 - 07:12:39 EST


On Mon, Feb 14, 2022 at 11:52 AM Rasmus Villemoes
<linux@xxxxxxxxxxxxxxxxxx> wrote:
>
> I think the point is for vsnprintf() to call (back) into Rust code.

Indeed, this is the case.

> That said, I don't like the !CONFIG_RUST version to return NULL, that
> will surely crash moments later.
>
> So I prefer something like
>
> [rust.h]
> // no CONFIG_RUST conditional
> +char *rust_fmt_argument(char* buf, char* end, void *ptr);
>
> [vsprintf.c]
> + case 'A':
> + if (IS_ENABLED(CONFIG_RUST))
> + return rust_fmt_argument(buf, end, ptr);
> + else
> + return string_nocheck(buf, end, "[%pA in non-Rust
> code?!]", default_str_spec);

Sounds good. Or perhaps simply `break` and let it print the pointer
(to be consistent with `g` case and non-error `e` case).

Cheers,
Miguel