guard when data is NULL

[build] ../../3rd/lwip/src/include/lwip/opt.h:137:41: error: argument 2 null where non-null expected [-Werror=nonnull]
[build]  #define MEMCPY(dst,src,len)             memcpy(dst,src,len)
[build]                                          ^~~~~~~~~~~~~~~~~~~
[build] ../../3rd/lwip/src/netif/ppp/fsm.c:791:7: note: in expansion of macro 'MEMCPY'
[build]        MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen);
[build]        ^~~~~~
[build] In file included from c:\mentorgraphics\fly380s_8910\prebuilts\win32\gcc-arm-none-eabi\arm-none-eabi\include\sys\time.h:40:0,
[build]                  from ../../3rd/../src/cat1/arch/cc.h:40,
[build]                  from ../../3rd/lwip/src/include/lwip/arch.h:50,
[build]                  from ../../3rd/lwip/src/include/lwip/debug.h:40,
[build]                  from ../../3rd/lwip/src/include/lwip/opt.h:52,
[build]                  from ../../3rd/lwip/src/include/netif/ppp/ppp_opts.h:31,
[build]                  from ../../3rd/lwip/src/netif/ppp/fsm.c:43:
[build] c:\mentorgraphics\fly380s_8910\prebuilts\win32\gcc-arm-none-eabi\arm-none-eabi\include\string.h:31:8: note: in a call to function 'memcpy' declared here
[build]  _PTR   _EXFUN(memcpy,(_PTR __restrict, const _PTR __restrict, size_t));
[build]         ^
This commit is contained in:
Yonggang Luo 2021-04-08 20:04:27 +08:00 committed by Simon Goldschmidt
parent 14444c1c7f
commit dad8c4c72a

View File

@ -787,8 +787,9 @@ void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen)
}
outp = (u_char*)p->payload;
if (datalen) /* && data != outp + PPP_HDRLEN + HEADERLEN) -- was only for fsm_sconfreq() */
MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen);
if (datalen && data != NULL) { /* && data != outp + PPP_HDRLEN + HEADERLEN) -- was only for fsm_sconfreq() */
MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen);
}
MAKEHEADER(outp, f->protocol);
PUTCHAR(code, outp);
PUTCHAR(id, outp);