]> git.sur5r.net Git - u-boot/commitdiff
net: tftp: silence a subscript above array bounds compile time warning
authorVladimir Zapolskiy <vz@mleia.com>
Wed, 28 Jun 2017 19:56:07 +0000 (22:56 +0300)
committerJoe Hershberger <joe.hershberger@ni.com>
Mon, 7 Aug 2017 20:18:29 +0000 (15:18 -0500)
For strncpy() select a minimal string length of destination and source
strings, here DEFAULT_NAME_LEN is preferable to MAX_LEN.

Due to the NUL-terminated contents of default_string the change is
a noop, however it removes a compilation warning if SH2/3/4 platform
specific strncpy() function is used:

  In file included from include/linux/string.h:21:0,
                   from include/common.h:28,
                   from net/tftp.c:9:

  net/tftp.c: In function 'tftp_start':
  arch/sh/include/asm/string.h:52:42: warning: array subscript is above array bounds [-Warray-bounds]
     : "0" (__dest), "1" (__src), "r" (__src+__n)

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
net/tftp.c

index ced45ec1f1f4aa836670115a8be30bf2e507b291..61e1671068039f2be225e5a8b0af9164237fbaa9 100644 (file)
@@ -742,8 +742,8 @@ void tftp_start(enum proto_t protocol)
                        (net_ip.s_addr >> 16) & 0xFF,
                        (net_ip.s_addr >> 24) & 0xFF);
 
-               strncpy(tftp_filename, default_filename, MAX_LEN);
-               tftp_filename[MAX_LEN - 1] = 0;
+               strncpy(tftp_filename, default_filename, DEFAULT_NAME_LEN);
+               tftp_filename[DEFAULT_NAME_LEN - 1] = 0;
 
                printf("*** Warning: no boot file name; using '%s'\n",
                       tftp_filename);