From: David Laight <David.Laight@ACULAB.COM>
To: "'Kees Cook'" <keescook@chromium.org>, Denis Efremov <efremov@linux.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Alex Dewar <alex.dewar90@gmail.com>,
"accessrunner-general@lists.sourceforge.net"
<accessrunner-general@lists.sourceforge.net>,
Joe Perches <joe@perches.com>, cocci <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs
Date: Fri, 28 Aug 2020 07:39:25 +0000 [thread overview]
Message-ID: <24d45f0868b74a3ba4924f031e968c55@AcuMS.aculab.com> (raw)
In-Reply-To: <202008271517.ECC1F1F8F@keescook>
From: Kees Cook
> Sent: 27 August 2020 23:21
...
>
> Agreed. This just makes me cringe. If the API design declares that when
> a show() callback starts, buf has been allocated with PAGE_SIZE bytes,
> then that's how the logic should proceed, and it should be using
> scnprintf...
>
> show(...) {
> size_t remaining = PAGE_SIZE;
>
> ...
> remaining -= scnprintf(buf, remaining, "fmt", var args ...);
> remaining -= scnprintf(buf, remaining, "fmt", var args ...);
> remaining -= scnprintf(buf, remaining, "fmt", var args ...);
Not quite what you had in mind, maybe:
char *end = buf + PAGE_SIZE;
buf += scnprintf(buf, end - buf, ...);
return PAGE_SIZE - (end - buf);
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
next prev parent reply other threads:[~2020-08-28 19:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200824222322.22962-1-alex.dewar90@gmail.com>
[not found] ` <48f2dc90-7852-eaf1-55d7-2c85cf954688@rasmusvillemoes.dk>
[not found] ` <20200827071537.GA168593@kroah.com>
[not found] ` <20200827131819.7rcl2f5js3hkoqj2@lenovo-laptop>
[not found] ` <def24e9e-018c-9712-0d07-d4cbc84f07d9@rasmusvillemoes.dk>
[not found] ` <20200827144846.yauuttjaqtxaldxg@lenovo-laptop>
2020-08-27 16:58 ` [Cocci] [PATCH] usb: atm: don't use snprintf() for sysfs attrs Joe Perches
2020-08-27 19:42 ` Julia Lawall
2020-08-27 20:29 ` Joe Perches
2020-08-27 21:00 ` Joe Perches
2020-08-27 21:29 ` Julia Lawall
2020-08-27 22:03 ` David Laight
2020-08-27 22:11 ` Joe Perches
2020-08-27 22:16 ` Kees Cook
2020-08-27 21:01 ` Denis Efremov
2020-08-27 21:36 ` Julia Lawall
2020-08-27 21:44 ` Joe Perches
2020-08-27 22:38 ` Denis Efremov
2020-08-27 22:48 ` Joe Perches
2020-08-27 22:20 ` Kees Cook
2020-08-27 22:45 ` Joe Perches
2020-08-28 4:12 ` Joe Perches
2020-08-28 7:58 ` Kees Cook
2020-08-28 8:10 ` Joe Perches
2020-08-28 8:22 ` Joe Perches
2020-08-28 7:39 ` David Laight [this message]
2020-08-27 21:54 ` David Laight
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=24d45f0868b74a3ba4924f031e968c55@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=accessrunner-general@lists.sourceforge.net \
--cc=alex.dewar90@gmail.com \
--cc=cocci@systeme.lip6.fr \
--cc=efremov@linux.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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;
as well as URLs for NNTP newsgroup(s).