All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	zhanggenjian@kylinos.cn, ricardo@marliere.net,
	bvanassche@acm.org, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] mips: sgi-ip22: Replace "s[n]?printf" with sysfs_emit in sysfs callbacks
Date: Thu, 17 Oct 2024 21:58:02 +1300	[thread overview]
Message-ID: <ZxDRmlDbtjEaTH8z@mail.google.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2410150220160.40463@angie.orcam.me.uk>

On Tue, Oct 15, 2024 at 03:01:13AM +0100, Maciej W. Rozycki wrote:
> On Tue, 15 Oct 2024, Paulo Miguel Almeida wrote:
> 
> > snprintf() has the documented, but still rather strange trait of
> > returning the length of the data that *would have been* written to the
> > array if space were available, rather than the arguably more useful
> > length of data *actually* written, [...]
> 
>  Why do you think that just returning `n - 1' in the case of a length 
> overflow would be more useful than returning the unmet buffer length 
> requirement?  I think the opposite is the case: the value returned lets 
> you reallocate the buffer for more space and retry, and there's no other 
> way to figure out how much this would be.  And if you need to know how 
> many characters were actually written, then `min(n - 1, snprintf(...))' 
> will do (and code you propose to replace does exactly that, open-coded).
> 
>  The change itself makes sense to me, but not your proposed description 
> I'm afraid.  Just replacing open-coded pieces with calls to `sysfs_emit' 
> is enough justification.
> 
>   Maciej

Thanks for taking the time to review this patch.

Will submit a v2 with the description you pointed out.

- Paulo A.

      reply	other threads:[~2024-10-17  8:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 20:59 [PATCH][next] mips: sgi-ip22: Replace "s[n]?printf" with sysfs_emit in sysfs callbacks Paulo Miguel Almeida
2024-10-15  2:01 ` Maciej W. Rozycki
2024-10-17  8:58   ` Paulo Miguel Almeida [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=ZxDRmlDbtjEaTH8z@mail.google.com \
    --to=paulo.miguel.almeida.rodenas@gmail.com \
    --cc=bvanassche@acm.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=ricardo@marliere.net \
    --cc=tsbogend@alpha.franken.de \
    --cc=zhanggenjian@kylinos.cn \
    /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.