From 4de725748239e122b27ff2b31aac32b835e8a2d6 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 7 Mar 2015 07:18:08 +0000 Subject: [PATCH] More MISRA. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7725 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/STM32/RT-STM32F407-DISCOVERY/pclint/waivers.lnt | 7 ++++++- os/rt/include/chqueues.h | 4 ++-- os/rt/ports/ARMCMx/chcore_v7m.h | 6 ++---- os/rt/src/chheap.c | 4 ++-- os/rt/src/chschd.c | 6 +++--- test/rt/testbuild/pclint/waivers.lnt | 7 ++++++- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/demos/STM32/RT-STM32F407-DISCOVERY/pclint/waivers.lnt b/demos/STM32/RT-STM32F407-DISCOVERY/pclint/waivers.lnt index bb9742582..8f441be43 100644 --- a/demos/STM32/RT-STM32F407-DISCOVERY/pclint/waivers.lnt +++ b/demos/STM32/RT-STM32F407-DISCOVERY/pclint/waivers.lnt @@ -1,11 +1,16 @@ /* MISRA checks are not performed in header files marked as libraries or vendor-provided files or belonging to other subsystems.*/ --elib(*) +-e686 /* Silencing warning on -elib(*) */ +-elib(*) /* No checks on library files. */ +libclass(angle,ansi) +libh(core_cm4.h) +libh(stm32f4xx.h) +libh(*LLD.h) +/* Silencing common non-MISRA info generated by PCLint in -w3 mode. All of + them have been controlled. Other infos have been fixed in the code.*/ +-e526 -e537 -e714 -e716 -e757 -e759 -e768 -e773 -e826 -e835 -e845 + /* Removing *advisory* directives and rules that would negatively impact code readability or not avoidable.*/ -e970 /* Dir-4.6 */ diff --git a/os/rt/include/chqueues.h b/os/rt/include/chqueues.h index f38a9ff75..232501469 100644 --- a/os/rt/include/chqueues.h +++ b/os/rt/include/chqueues.h @@ -304,7 +304,7 @@ static inline bool chIQIsEmptyI(input_queue_t *iqp) { chDbgCheckClassI(); - return (bool)(chQSpaceI(iqp) <= 0U); + return (bool)(chQSpaceI(iqp) == 0U); } /** @@ -404,7 +404,7 @@ static inline bool chOQIsFullI(output_queue_t *oqp) { chDbgCheckClassI(); - return (bool)(chQSpaceI(oqp) <= 0U); + return (bool)(chQSpaceI(oqp) == 0U); } /** diff --git a/os/rt/ports/ARMCMx/chcore_v7m.h b/os/rt/ports/ARMCMx/chcore_v7m.h index 761cffea7..b4fafc736 100644 --- a/os/rt/ports/ARMCMx/chcore_v7m.h +++ b/os/rt/ports/ARMCMx/chcore_v7m.h @@ -282,15 +282,13 @@ struct port_intctx { * by an @p port_intctx structure. */ #define PORT_SETUP_CONTEXT(tp, workspace, wsize, pf, arg) { \ - /*lint -save -e9087 [11.3] Normal pointers arithmetic.*/ \ + /*lint -save -e611 -e9074 -e9087 [11.1, 11.3] Casts are planned here.*/ \ (tp)->p_ctx.r13 = (struct port_intctx *)((uint8_t *)(workspace) + \ (size_t)(wsize) - \ sizeof(struct port_intctx)); \ - /*lint -restore*/ \ - /*lint -save -e9074 -e9087 [11.1, 11.3] Casts are planned here.*/ \ (tp)->p_ctx.r13->r4 = (regarm_t)(pf); \ (tp)->p_ctx.r13->r5 = (regarm_t)(arg); \ - (tp)->p_ctx.r13->lr = (regarm_t)(_port_thread_start); \ + (tp)->p_ctx.r13->lr = (regarm_t)_port_thread_start; \ /*lint -restore*/ \ } diff --git a/os/rt/src/chheap.c b/os/rt/src/chheap.c index a2635c72d..5214462ce 100644 --- a/os/rt/src/chheap.c +++ b/os/rt/src/chheap.c @@ -110,7 +110,7 @@ void chHeapObjectInit(memory_heap_t *heapp, void *buf, size_t size) { chDbgCheck(MEM_IS_ALIGNED(buf) && MEM_IS_ALIGNED(size)); - heapp->h_provider = (memgetfunc_t)NULL; + heapp->h_provider = NULL; heapp->h_free.h.u.next = hp; heapp->h_free.h.size = 0; hp->h.u.next = NULL; @@ -162,7 +162,7 @@ void *chHeapAlloc(memory_heap_t *heapp, size_t size) { /* Block bigger enough, must split it.*/ fp = (void *)((uint8_t *)(hp) + sizeof(union heap_header) + size); fp->h.u.next = hp->h.u.next; - fp->h.size = hp->h.size - sizeof(union heap_header) - size; + fp->h.size = (hp->h.size - sizeof(union heap_header)) - size; qp->h.u.next = fp; hp->h.size = size; } diff --git a/os/rt/src/chschd.c b/os/rt/src/chschd.c index 3de92aec8..ba377ac4a 100644 --- a/os/rt/src/chschd.c +++ b/os/rt/src/chschd.c @@ -389,9 +389,9 @@ void chSchWakeupS(thread_t *ntp, msg_t msg) { thread_t *otp = chSchReadyI(currp); setcurrp(ntp); #if defined(CH_CFG_IDLE_LEAVE_HOOK) - if (otp->p_prio == IDLEPRIO) { - CH_CFG_IDLE_LEAVE_HOOK(); - } + if (otp->p_prio == IDLEPRIO) { + CH_CFG_IDLE_LEAVE_HOOK(); + } #endif ntp->p_state = CH_STATE_CURRENT; chSysSwitch(ntp, otp); diff --git a/test/rt/testbuild/pclint/waivers.lnt b/test/rt/testbuild/pclint/waivers.lnt index bb9742582..8f441be43 100644 --- a/test/rt/testbuild/pclint/waivers.lnt +++ b/test/rt/testbuild/pclint/waivers.lnt @@ -1,11 +1,16 @@ /* MISRA checks are not performed in header files marked as libraries or vendor-provided files or belonging to other subsystems.*/ --elib(*) +-e686 /* Silencing warning on -elib(*) */ +-elib(*) /* No checks on library files. */ +libclass(angle,ansi) +libh(core_cm4.h) +libh(stm32f4xx.h) +libh(*LLD.h) +/* Silencing common non-MISRA info generated by PCLint in -w3 mode. All of + them have been controlled. Other infos have been fixed in the code.*/ +-e526 -e537 -e714 -e716 -e757 -e759 -e768 -e773 -e826 -e835 -e845 + /* Removing *advisory* directives and rules that would negatively impact code readability or not avoidable.*/ -e970 /* Dir-4.6 */