linux_dsm_epyc7002/arch/tile/gxio
Chris Metcalf bceb7efa6a tile gxio: use better string copy primitive
Both strncpy and strlcpy suffer from the fact that they do
partial copies of strings into the destination when the target
buffer is too small.  This is frequently pointless since an
overflow of the target buffer may make the result invalid.

strncpy() makes it relatively hard to even detect the error
condition, and with strlcpy() you have to duplicate the buffer
size parameter to test to see if the result exceeds it.
By returning zero in the failure case, we both make testing
for it easy, and by simply not copying anything in that case,
we make it mandatory for callers to test the error code.

To catch lazy programmers who don't check, we also place a NUL at
the start of the destination buffer (if there is space) to
ensure that the result is an invalid string.

At some point it may make sense to promote strscpy() to
a global platform-independent function, but other than the
reviewers, no one was interested on LKML, so for now leave
the strscpy() function as file-static.

Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
2014-10-02 10:19:34 -04:00
..
dma_queue.c arch/tile: common DMA code for the GXIO IORPC subsystem 2012-07-11 16:04:54 -04:00
iorpc_globals.c
iorpc_mpipe_info.c tile: improve gxio iorpc autogenerated code style 2013-09-16 15:47:20 -04:00
iorpc_mpipe.c tile: improve gxio iorpc autogenerated code style 2013-09-16 15:47:20 -04:00
iorpc_trio.c tile: improve gxio iorpc autogenerated code style 2013-09-16 15:47:20 -04:00
iorpc_uart.c tilegx: provide kernel support for the tilegx UART shim 2013-09-03 14:50:36 -04:00
iorpc_usb_host.c tile: improve gxio iorpc autogenerated code style 2013-09-16 15:47:20 -04:00
Kconfig tilegx: provide kernel support for the tilegx UART shim 2013-09-03 14:50:36 -04:00
kiorpc.c
Makefile tilegx: provide kernel support for the tilegx UART shim 2013-09-03 14:50:36 -04:00
mpipe.c tile gxio: use better string copy primitive 2014-10-02 10:19:34 -04:00
trio.c arch/tile: provide kernel support for the tilegx TRIO shim 2012-07-11 16:04:58 -04:00
uart.c tilegx: provide kernel support for the tilegx UART shim 2013-09-03 14:50:36 -04:00
usb_host.c tile: improve gxio iorpc autogenerated code style 2013-09-16 15:47:20 -04:00