Re: [PATCH] staging: rtl8712: Replace snprintf with scnprintf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux