From: Candy Febriyanto <cfebriyanto@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
hdegoede@redhat.com, Larry.Finger@lwfinger.net
Subject: Re: [PATCH 3/3] staging: rtl8723bs: os_dep: Replace sprintf with scnprintf
Date: Mon, 1 Mar 2021 21:01:54 +0700 [thread overview]
Message-ID: <YDzz0kfj/PKSnIWD@mainframe> (raw)
In-Reply-To: <20210301134109.GS2087@kadam>
On Mon, Mar 01, 2021 at 04:41:09PM +0300, Dan Carpenter wrote:
> On Mon, Mar 01, 2021 at 08:13:54PM +0700, Candy Febriyanto wrote:
> > @@ -5082,7 +5084,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
> > case IW_PRIV_TYPE_BYTE:
> > /* Display args */
> > for (j = 0; j < n; j++) {
> > - sprintf(str, "%d ", extra[j]);
> > + scnprintf(str, sizeof(str), "%d ", extra[j]);
> > len = strlen(str);
>
> You could save a little code and combine the two statements:
>
> len = scnprintf(str, sizeof(str), "%d ", extra[j]);
Good catch, I'll send a V2.
>
> For bonus points, you could write a Coccinelle script to look for that
> pattern of calling strlen() on a freshly sprintfed string.
Sounds like a good idea, I don't know how to do it though so feel free.
>
> > output_len = strlen(output);
> > if ((output_len + len + 1) > 4096) {
>
> regards,
> dan carpenter
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2021-03-01 14:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 13:12 [PATCH 0/3] staging: rtl8723bs: Replace sprintf with scnprintf Candy Febriyanto
2021-03-01 13:12 ` [PATCH 1/3] staging: rtl8723bs: core: " Candy Febriyanto
2021-03-01 13:13 ` [PATCH 2/3] staging: rtl8723bs: hal: " Candy Febriyanto
2021-03-01 13:13 ` [PATCH 3/3] staging: rtl8723bs: os_dep: " Candy Febriyanto
2021-03-01 13:41 ` Dan Carpenter
2021-03-01 14:01 ` Candy Febriyanto [this message]
2021-03-01 13:45 ` [PATCH 0/3] staging: rtl8723bs: " Hans de Goede
2021-03-01 14:02 ` Candy Febriyanto
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=YDzz0kfj/PKSnIWD@mainframe \
--to=cfebriyanto@gmail.com \
--cc=Larry.Finger@lwfinger.net \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
/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).