From: Dan Carpenter <dan.carpenter@oracle.com>
To: Rohit Sarkar <rohitsarkar5398@gmail.com>
Cc: gregkh@linuxfoundation.org,
driverdev-devel@linuxdriverproject.org,
florian.c.schilhabel@googlemail.com, larry.finger@lwfiner.net
Subject: Re: [PATCH] staging: rtl8712: Replace snprintf with scnprintf
Date: Wed, 2 Oct 2019 13:57:22 +0300 [thread overview]
Message-ID: <20191002105722.GL22609@kadam> (raw)
In-Reply-To: <20191002043350.GB11819@SARKAR>
On Wed, Oct 02, 2019 at 10:03:51AM +0530, Rohit Sarkar wrote:
> On Tue, Oct 01, 2019 at 10:00:56PM +0300, Dan Carpenter wrote:
> >
> > No. scnprintf() returns the number of characters *not counting the
> > NUL terminator*. So it can be a maximum of MAX_WPA_IE_LEN - 1.
> >
> > regards,
> > dan carpenter
>
> TIL :)
> Would the better approach be to just remove the loop or break when n ==
> MAX_WPA_IE_LEN - 1.
We could leave it as is or change it to "MAX_WPA_IE_LEN - 1". But I
feel like the default should be to leave it as is unless there is a good
reason.
So from a static analysis perspective we wouldn't complain unless/until
the "n" is re-used outside the loop. So this a chance to make a smarter
static analyzer.
regards,
dan carpenter
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2019-10-02 10:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-10 18:49 [PATCH] staging: rtl8712: Replace snprintf with scnprintf Rohit Sarkar
2019-09-10 18:55 ` Rohit Sarkar
2019-10-01 14:14 ` Dan Carpenter
2019-10-01 8:45 ` Dan Carpenter
2019-10-01 17:39 ` Rohit Sarkar
2019-10-01 19:00 ` Dan Carpenter
2019-10-02 4:33 ` Rohit Sarkar
2019-10-02 10:57 ` Dan Carpenter [this message]
2019-10-02 11:42 ` Rohit Sarkar
2019-10-02 12:06 ` Dan Carpenter
2019-10-02 12:10 ` Rohit Sarkar
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=20191002105722.GL22609@kadam \
--to=dan.carpenter@oracle.com \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=florian.c.schilhabel@googlemail.com \
--cc=gregkh@linuxfoundation.org \
--cc=larry.finger@lwfiner.net \
--cc=rohitsarkar5398@gmail.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).