This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5eaf44af841e25caaba49447b66205cac919d854 Author: Marco Casaroli <[email protected]> AuthorDate: Sun Nov 8 18:46:16 2026 +0100 sched_note: Accept a pointer to an incomplete type in sched_note_printf(). With CONFIG_DRIVERS_NOTE_STRIP_FORMAT, sched_note_printf() finds the type of each argument with _Generic((arg) + 0, ...) and sizeof((arg) + 0). The "+ 0" promotes small integers and turns arrays into pointers. But arithmetic on a pointer to an incomplete type is not allowed, so a call that prints such a pointer with %p does not build. With CONFIG_SYSLOG_TO_SCHED_NOTE, debug messages do this: rptun/rptun.c:486:11: error: invalid use of undefined type 'struct mm_heap_s' net/tcp/tcp_dump.c:69:3: error: invalid use of undefined type 'struct net_driver_s' Use (0 ? 0 : (arg)) instead. It gives the same type as (arg) + 0 for integers, floating types, arrays and pointers, and it accepts any pointer. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- include/nuttx/sched_note.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h index bb30b2a9f53..8e0c8c3c3ad 100644 --- a/include/nuttx/sched_note.h +++ b/include/nuttx/sched_note.h @@ -143,9 +143,16 @@ #define NOTE_PRINTF_GET_TYPE(tag, index) (((tag) >> (index) * 2) & 0x03) #define NOTE_PRINTF_GET_COUNT(tag) (((tag) >> 28) & 0x0f) +/* Promote an argument as "arg + 0" does, but also accept a pointer to an + * incomplete type, which "arg + 0" rejects. + */ + +#define NOTE_PRINTF_PROMOTE(arg) (0 ? 0 : (arg)) + /* Check if a variable is 32-bit or 64-bit */ -#define NOTE_PRINTF_INT_TYPE(arg) (sizeof((arg) + 0) <= sizeof(uint32_t) ? \ +#define NOTE_PRINTF_INT_TYPE(arg) (sizeof(NOTE_PRINTF_PROMOTE(arg)) <= \ + sizeof(uint32_t) ? \ NOTE_PRINTF_UINT32 : NOTE_PRINTF_UINT64) /* Use the object size to mark strings of known size. This is the builtin: @@ -159,7 +166,7 @@ /* Use _Generic to determine the type of the parameter */ #define NOTE_PRINTF_ARG_TYPE(__arg__) \ - _Generic((__arg__) + 0, \ + _Generic(NOTE_PRINTF_PROMOTE(__arg__), \ float : NOTE_PRINTF_DOUBLE, \ double: NOTE_PRINTF_DOUBLE, \ char *: ({NOTE_PRINTF_OBJECT_SIZE(__arg__) > 0 ? \
