On 2022-01-20 13:11, Xiang Xiao wrote:
On Thu, Jan 20, 2022 at 7:33 PM Jukka Laitinen <jukka.laiti...@iki.fi>
wrote:
Hi,
Sorry if this question comes several times, it seems that for some
reason my emails are not always coming through to the mailing list... So
re-sending.
I started getting this build error from the latest NuttX:
misc/lib_execinfo.c:45:17: error: null argument where non-null required
(argument 1) [-Werror=nonnull]
45 | int ret = sprintf(NULL, "%pS", *buffer++);
| ^~~~~~~
In function 'backtrace_malloc',
inlined from 'backtrace_symbols' at misc/lib_execinfo.c:67:10:
misc/lib_execinfo.c:45:17: error: null destination pointer
[-Werror=format-overflow=]
45 | int ret = sprintf(NULL, "%pS", *buffer++);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
What is the deal with sprintf to NULL ptr?
The code wants to get the length of the formatted string. But, the right
API is snprintf, not sprintf. Could you try this:
https://github.com/apache/incubator-nuttx/pull/5290
Uhm, no, the first parameter is the target buffer location. That cannot
be a NULL pointer.
I fully agree on the snprintf recommendation to prevent overflows.
Arie