Skip to content

Commit

Permalink
guard when data is NULL
Browse files Browse the repository at this point in the history
[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]         ^
  • Loading branch information
lygstate authored and goldsimon committed Sep 29, 2023
1 parent 14444c1 commit dad8c4c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/netif/ppp/fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit dad8c4c

Please sign in to comment.