[U-Boot-Users] [PATCH] TFTP: add host ip addr support

Wolfgang Denk
2008-01-16T21:23:07Z

In message <478E6D5A.4070807@gmail.com> you wrote:
>
> #define MAX_LEN 80
> static char tftp_filename[MAX_LEN + 1];
> memset(tftp_filename[MAX_LEN], 0, 1);

warning: passing argument 1 of 'memset' makes pointer from integer without a cast

> strncpy(tftp_filename, str, MAX_LEN);
>
>
> Better?

No, definitely not.

First, the compiler will issue a warning; second, using memcpy() to
store a single character is serious overkill - why don't you simply
use "tftp_filename[MAX_LEN] = '\0';" ?;and third - the real bug - the
strncpy will happily overwrite the 0 you placed there before.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I can call spirits from the vasty deep."
"Why so can I, or so can any man; but will they come when you do call
for them?" - Shakespeare, 1 King Henry IV, Act III, Scene I.