All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Remo Senekowitsch" <remo@buenzli.dev>
To: "Rasmus Villemoes" <linux@rasmusvillemoes.dk>
Cc: "Petr Mladek" <pmladek@suse.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Sergey Senozhatsky" <senozhatsky@chromium.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: Exporting functions from vsprintf.c for Rust
Date: Mon, 14 Apr 2025 13:47:19 +0200	[thread overview]
Message-ID: <D96C5R3AENKF.SYMOHIO4NZLB@buenzli.dev> (raw)
In-Reply-To: <CAKwiHFi_egfePDdXQEtYNvO-U65O==MosHNQ7Vm4F6iudJs95g@mail.gmail.com>

On Fri Apr 11, 2025 at 3:43 PM CEST, Rasmus Villemoes wrote:
> On Fri, Apr 11, 2025, 13:36 Remo Senekowitsch <remo@buenzli.dev> wrote:
>
>> On Fri Apr 11, 2025 at 11:42 AM CEST, Petr Mladek wrote:
>> >
>> > Honestly, I do not have a good feeling about exporting the internal
>> > vsprintf() functions. They have a very specific semantic.
>> >
>> > Especially, they return pointer to the next-to-write character.
>> > And it might be even beyond the given *end pointer. It is because, for
>> > example, vsnprintf() returns the number of characters which would
>> > have been written to the buffer when it was big enough.
>> >
>> > Instead, I suggest to create a wrapper which would have a sane
>> > semantic and call scnprintf() internally. Something like:
>> >
>> > int fwnode_full_name_to_string(char *buf, size_t size,
>> >                              struct fwnode_handle *fwnode)
>> > {
>> >       return scnprintf(buf, size, "%pfwf", fwnode);
>> > }
>>
>> That makes sense. I tried your suggestion and it works, thank you!
>>
>>
> But is a wrapper even needed for this? Can't the appropriate sprintf
> variant just be called from Rust with that %pfwf format string?

Yeah, that works. Seems like the simplest solution - no C changes needed.
Thanks!

Remo

      parent reply	other threads:[~2025-04-14 11:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <D931ZH9KRY2E.2D7HN6QWELGFJ@buenzli.dev>
2025-04-11  9:42 ` Exporting functions from vsprintf.c for Rust Petr Mladek
2025-04-11 11:36   ` Remo Senekowitsch
     [not found]     ` <CAKwiHFi_egfePDdXQEtYNvO-U65O==MosHNQ7Vm4F6iudJs95g@mail.gmail.com>
2025-04-14  6:59       ` Andy Shevchenko
2025-04-14 11:47       ` Remo Senekowitsch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D96C5R3AENKF.SYMOHIO4NZLB@buenzli.dev \
    --to=remo@buenzli.dev \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.