diff options
| author | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-02-06 18:15:51 +0000 | 
|---|---|---|
| committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-02-06 18:15:51 +0000 | 
| commit | a947a1d5ae074f341716d2478922a6d23208bb77 (patch) | |
| tree | cb9faa577d78fcd6135248e9226c42382e974118 | |
| parent | 069482ac06372bd9e184f6281399ae4731af375d (diff) | |
| download | ChibiOS-a947a1d5ae074f341716d2478922a6d23208bb77.tar.gz ChibiOS-a947a1d5ae074f341716d2478922a6d23208bb77.tar.bz2 ChibiOS-a947a1d5ae074f341716d2478922a6d23208bb77.zip  | |
MISRA-related fixes.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11455 35acf78f-673a-0410-8e92-d51de3d6d3f4
| -rw-r--r-- | os/common/oslib/include/chfactory.h | 12 | ||||
| -rw-r--r-- | os/common/oslib/src/chfactory.c | 20 | ||||
| -rw-r--r-- | os/common/oslib/src/chheap.c | 2 | ||||
| -rw-r--r-- | os/rt/include/chsys.h | 1 | ||||
| -rw-r--r-- | os/rt/src/chthreads.c | 4 | ||||
| -rw-r--r-- | test/rt/testbuild/chconf.h | 9 | 
6 files changed, 23 insertions, 25 deletions
diff --git a/os/common/oslib/include/chfactory.h b/os/common/oslib/include/chfactory.h index ec2bd4c3e..a2f27c626 100644 --- a/os/common/oslib/include/chfactory.h +++ b/os/common/oslib/include/chfactory.h @@ -111,11 +111,11 @@  #error "CH_CFG_USE_FACTORY requires CH_CFG_USE_MEMCORE"
  #endif
 -#if (CH_FACTORY_REQUIRES_POOLS == TRUE) && (CH_CFG_USE_MEMPOOLS == FALSE)
 +#if CH_FACTORY_REQUIRES_POOLS && (CH_CFG_USE_MEMPOOLS == FALSE)
  #error "CH_CFG_USE_MEMPOOLS is required"
  #endif
 -#if (CH_FACTORY_REQUIRES_HEAP == TRUE) && (CH_CFG_USE_HEAP == FALSE)
 +#if CH_FACTORY_REQUIRES_HEAP && (CH_CFG_USE_HEAP == FALSE)
  #error "CH_CFG_USE_HEAP is required"
  #endif
 @@ -187,11 +187,13 @@ typedef struct ch_dyn_object {     * @brief   List element of the dynamic buffer object.
     */
    dyn_element_t         element;
 +  /*lint -save -e9038 [18.7] Required by design.*/
    /**
     * @brief   The buffer.
     * @note    This requires C99.
     */
    uint8_t               buffer[];
 +  /*lint restore*/
  } dyn_buffer_t;
  #endif
 @@ -224,11 +226,13 @@ typedef struct ch_dyn_mailbox {     * @brief   The mailbox.
     */
    mailbox_t             mbx;
 -  /**
 +  /*lint -save -e9038 [18.7] Required by design.*/
 + /**
     * @brief   Messages buffer.
     * @note    This requires C99.
     */
    msg_t                 msgbuf[];
 +  /*lint restore*/
  } dyn_mailbox_t;
  #endif
 @@ -245,6 +249,7 @@ typedef struct ch_dyn_objects_fifo {     * @brief   The objects FIFO.
     */
    objects_fifo_t        fifo;
 +  /*lint -save -e9038 [18.7] Required by design.*/
    /**
     * @brief   Messages buffer.
     * @note    This open array is followed by another area containing the
 @@ -252,6 +257,7 @@ typedef struct ch_dyn_objects_fifo {     * @note    This requires C99.
     */
    msg_t                 msgbuf[];
 +  /*lint restore*/
  } dyn_objects_fifo_t;
  #endif
 diff --git a/os/common/oslib/src/chfactory.c b/os/common/oslib/src/chfactory.c index 57fe9f85c..05a4f5d8e 100644 --- a/os/common/oslib/src/chfactory.c +++ b/os/common/oslib/src/chfactory.c @@ -120,7 +120,7 @@ static dyn_element_t *dyn_list_unlink(dyn_element_t *element,    return NULL;
  }
 -#if (CH_FACTORY_REQUIRES_HEAP == TRUE) || defined(__DOXYGEN__)
 +#if CH_FACTORY_REQUIRES_HEAP || defined(__DOXYGEN__)
  static dyn_element_t *dyn_create_object_heap(const char *name,
                                               dyn_list_t *dlp,
                                               size_t size) {
 @@ -142,7 +142,7 @@ static dyn_element_t *dyn_create_object_heap(const char *name,    /* Initializing object list element.*/
    strncpy(dep->name, name, CH_CFG_FACTORY_MAX_NAMES_LENGTH);
 -  dep->refs = 1U;
 +  dep->refs = (ucnt_t)1;
    dep->next = dlp->next;
    /* Updating factory list.*/
 @@ -155,18 +155,18 @@ static void dyn_release_object_heap(dyn_element_t *dep,                                      dyn_list_t *dlp) {
    chDbgCheck(dep != NULL);
 -  chDbgAssert(dep->refs > 0U, "invalid references number");
 +  chDbgAssert(dep->refs > (ucnt_t)0, "invalid references number");
    dep->refs--;
 -  if (dep->refs == 0U) {
 +  if (dep->refs == (ucnt_t)0) {
      dep = dyn_list_unlink(dep, dlp);
      chHeapFree((void *)dep);
    }
  }
 -#endif /* CH_FACTORY_REQUIRES_HEAP == TRUE */
 +#endif /* CH_FACTORY_REQUIRES_HEAP */
 -#if (CH_FACTORY_REQUIRES_POOLS == TRUE) || defined(__DOXYGEN__)
 +#if CH_FACTORY_REQUIRES_POOLS || defined(__DOXYGEN__)
  static dyn_element_t *dyn_create_object_pool(const char *name,
                                               dyn_list_t *dlp,
                                               memory_pool_t *mp) {
 @@ -188,7 +188,7 @@ static dyn_element_t *dyn_create_object_pool(const char *name,    /* Initializing object list element.*/
    strncpy(dep->name, name, CH_CFG_FACTORY_MAX_NAMES_LENGTH);
 -  dep->refs = 1U;
 +  dep->refs = (ucnt_t)1;
    dep->next = dlp->next;
    /* Updating factory list.*/
 @@ -202,15 +202,15 @@ static void dyn_release_object_pool(dyn_element_t *dep,                                      memory_pool_t *mp) {
    chDbgCheck(dep != NULL);
 -  chDbgAssert(dep->refs > 0U, "invalid references number");
 +  chDbgAssert(dep->refs > (ucnt_t)0, "invalid references number");
    dep->refs--;
 -  if (dep->refs == 0U) {
 +  if (dep->refs == (ucnt_t)0) {
      dep = dyn_list_unlink(dep, dlp);
      chPoolFree(mp, (void *)dep);
    }
  }
 -#endif /* CH_FACTORY_REQUIRES_POOLS == TRUE */
 +#endif /* CH_FACTORY_REQUIRES_POOLS */
  static dyn_element_t *dyn_find_object(const char *name, dyn_list_t *dlp) {
    dyn_element_t *dep;
 diff --git a/os/common/oslib/src/chheap.c b/os/common/oslib/src/chheap.c index d6e2eeca6..d3d25458f 100644 --- a/os/common/oslib/src/chheap.c +++ b/os/common/oslib/src/chheap.c @@ -135,7 +135,9 @@ void chHeapObjectInit(memory_heap_t *heapp, void *buf, size_t size) {    /* Adjusting the size in case the initial block was not correctly
       aligned.*/
 +  /*lint -save -e9033 [10.8] Required cast operations.*/
    size -= (size_t)((uint8_t *)hp - (uint8_t *)buf);
 +  /*lint restore*/
    /* Initializing the heap header.*/
    heapp->provider = NULL;
 diff --git a/os/rt/include/chsys.h b/os/rt/include/chsys.h index d24bcabc1..8edf8773c 100644 --- a/os/rt/include/chsys.h +++ b/os/rt/include/chsys.h @@ -283,7 +283,6 @@ extern stkalign_t ch_idle_thread_wa[];  extern "C" {
  #endif
    void chSysInit(void);
 -  void chSysHalt(const char *reason);
    bool chSysIntegrityCheckI(unsigned testmask);
    void chSysTimerHandlerI(void);
    syssts_t chSysGetStatusAndLockX(void);
 diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c index ef740eaf9..4d0a641e9 100644 --- a/os/rt/src/chthreads.c +++ b/os/rt/src/chthreads.c @@ -281,7 +281,7 @@ thread_t *chThdCreate(const thread_descriptor_t *tdp) {    thread_t *tp;
  #if (CH_CFG_USE_REGISTRY == TRUE) &&                                        \
 -    (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
 +    ((CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE))
    chDbgAssert(chRegFindThreadByWorkingArea(tdp->wbase) == NULL,
                "working area in use");
  #endif
 @@ -331,7 +331,7 @@ thread_t *chThdCreateStatic(void *wsp, size_t size,               (prio <= HIGHPRIO) && (pf != NULL));
  #if (CH_CFG_USE_REGISTRY == TRUE) &&                                        \
 -    (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
 +    ((CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE))
    chDbgAssert(chRegFindThreadByWorkingArea(wsp) == NULL,
                "working area in use");
  #endif
 diff --git a/test/rt/testbuild/chconf.h b/test/rt/testbuild/chconf.h index 53147ba97..45159091d 100644 --- a/test/rt/testbuild/chconf.h +++ b/test/rt/testbuild/chconf.h @@ -572,15 +572,6 @@    /* Add threads custom fields here.*/
  /**
 - * @brief   System initialization hook.
 - * @details User initialization code added to the @p chSysInit() function
 - *          just before interrupts are enabled globally.
 - */
 -#define CH_CFG_SYSTEM_INIT_HOOK(tp) {                                       \
 -  /* Add threads initialization code here.*/                                \
 -}
 -
 -/**
   * @brief   Threads descriptor structure extension.
   * @details User fields added to the end of the @p thread_t structure.
   */
  | 
