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

On Fri, Apr 11, 2025 at 03:43:12PM +0200, 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?

+1 here. But if really really need that wrapper, it should go to property.h.

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2025-04-14  6:59 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 [this message]
2025-04-14 11:47       ` Remo Senekowitsch

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=Z_yyUmYoihvpP0_5@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=pmladek@suse.com \
    --cc=remo@buenzli.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox