From d26357d3e69b374aad08d5069fda741dc032be7e Mon Sep 17 00:00:00 2001 From: guoshichao Date: Mon, 24 Jun 2024 16:08:34 +0800 Subject: [PATCH] nuttx/math: fix greenhills build warning on using sizeof with operand the detailed warning info are: CC: syslog/vsyslog.c "pthread/pthread_create.c", line 443: warning #1931-D: operand of sizeof is not a type, variable, or dereferenced pointer expression ptcb->cmn.timeslice = MSEC2TICK(CONFIG_RR_INTERVAL); ^ CC: dirent/lib_closedir.c "sched/sched_profil.c", line 81: warning #1931-D: operand of sizeof is not a type, variable, or dereferenced pointer expression wd_start(&prof->timer, PROFTICK, profil_timer_handler, arg); ^ "sched/sched_profil.c", line 142: warning #1931-D: operand of sizeof is not a type, variable, or dereferenced pointer expression wd_start(&prof->timer, PROFTICK, profil_timer_handler, (wdparm_t)prof); ^ CC: common/arm_modifyreg8.c "sched/sched_setscheduler.c", line 165: warning #1931-D: operand of sizeof is not a type, variable, or dereferenced pointer expression tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL); ^ CC: misc/lib_utsname.c "sched/sched_unlock.c", line 275: warning #1931-D: operand of sizeof is not a type, variable, or dereferenced pointer expression rtcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL); ^ "sched/sched_roundrobin.c", line 119: warning #1931-D: operand of sizeof is not a type, variable, or dereferenced pointer expression tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL); ^ CC: armv7-m/arm_fpuconfig.c cxarm: Error: No files. Try -help. CC: misc/lib_crc8ccitt.c cxarm: Error: No files. Try -help. cxarm: Error: No files. Try -help. CC: getprime_main.c cxarm: Error: No files. Try -help. cxarm: Error: No files. Try -help. CC: misc/lib_log2ceil.c cxarm: Error: No files. Try -help. CC: task/task_start.c "task/task_setup.c", line 423: warning #1931-D: operand of sizeof is not a type, variable, or dereferenced pointer expression tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL); ^ Signed-off-by: guoshichao --- include/nuttx/lib/math32.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nuttx/lib/math32.h b/include/nuttx/lib/math32.h index acfd09749f6..07b955b4d0d 100644 --- a/include/nuttx/lib/math32.h +++ b/include/nuttx/lib/math32.h @@ -260,12 +260,12 @@ extern "C" }) # define div_const(n, base) \ - ((sizeof(n) == sizeof(uint64_t)) ? div64_const(n, base) : ((n) / (base))) + ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const(n, base) : ((n) / (base))) # define div_const_roundup(n, base) \ - ((sizeof(n) == sizeof(uint64_t)) ? div64_const((n) + (base) - 1, base) : \ + ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const((n) + (base) - 1, base) : \ (((n) + (base) - 1) / (base))) # define div_const_roundnearest(n, base) \ - ((sizeof(n) == sizeof(uint64_t)) ? div64_const((n) + ((base) / 2), base) : \ + ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const((n) + ((base) / 2), base) : \ (((n) + ((base) / 2)) / (base))) #else # define div_const(n, base) ((n) / (base))