[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DD0043824@AcuExch.aculab.com>
Date: Thu, 27 Jul 2017 10:15:35 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Jakub Kicinski' <jakub.kicinski@...ronome.com>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"oss-drivers@...ronome.com" <oss-drivers@...ronome.com>
Subject: RE: [PATCH net-next 2/3] nfp: look for firmware image by device
serial number and PCI name
From: Jakub Kicinski
> Sent: 27 July 2017 10:26
...
> > - use snprintf().
>
> To effectively print an integer into an amply sized array? I need to
> guarantee that the string will fit otherwise I would request a FW image
> with a wrong name. snprintf() would only mask such a bug.
Eh?
If, for any reason, the buffer isn't long enough snprintf() won't
write over random memory - sprint() will, and you may not notice.
> > - kill those hh, the arguments are of type 'int'.
>
> It doesn't matter. I will be more careful in the future, though.
>
> > In fact make 'interface' 'unsigned int' as well.
>
> It's a value read from the hardware, and it's 16 bits wide, therefore
> my preference it to explicitly size the variable.
Right, so you keep asking the compiler to generate code to mask
any arithmetic results (written into the variable) back down to
16 bits.
OTOH, looking at some of the functions in nfp_cppcore.c you don't
care about performance at all.
David
Powered by blists - more mailing lists