Skip to content

Commit

Permalink
nuttx/math: fix greenhills build warning on using sizeof with operand
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
guoshichao committed Sep 20, 2024
1 parent 44cce29 commit 8ecedcc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/nuttx/lib/math32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 8ecedcc

Please sign in to comment.