diff options
| author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-03-07 11:07:31 +0000 | 
|---|---|---|
| committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-03-07 11:07:31 +0000 | 
| commit | 272b51ba236d6636bda3ee961cba35eb489d30af (patch) | |
| tree | 2120de0e1054da930c0c54b7a071f5fd73ac3014 /os/rt | |
| parent | 57585301af1df353c3dd3a6e389d074bd4de4fcc (diff) | |
| download | ChibiOS-272b51ba236d6636bda3ee961cba35eb489d30af.tar.gz ChibiOS-272b51ba236d6636bda3ee961cba35eb489d30af.tar.bz2 ChibiOS-272b51ba236d6636bda3ee961cba35eb489d30af.zip | |
MISRAs done for RT.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7727 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt')
| -rw-r--r-- | os/rt/include/chdebug.h | 2 | ||||
| -rw-r--r-- | os/rt/include/chschd.h | 8 | ||||
| -rw-r--r-- | os/rt/include/chsys.h | 2 | ||||
| -rw-r--r-- | os/rt/include/chthreads.h | 2 | ||||
| -rw-r--r-- | os/rt/ports/SIMIA32/chcore.h | 2 | ||||
| -rw-r--r-- | os/rt/src/chdebug.c | 3 | ||||
| -rw-r--r-- | os/rt/src/chdynamic.c | 2 | ||||
| -rw-r--r-- | os/rt/src/chevents.c | 2 | ||||
| -rw-r--r-- | os/rt/src/chheap.c | 27 | ||||
| -rw-r--r-- | os/rt/src/chmempools.c | 4 | ||||
| -rw-r--r-- | os/rt/src/chqueues.c | 4 | ||||
| -rw-r--r-- | os/rt/src/chregistry.c | 2 | ||||
| -rw-r--r-- | os/rt/src/chschd.c | 24 | ||||
| -rw-r--r-- | os/rt/src/chthreads.c | 8 | 
14 files changed, 63 insertions, 29 deletions
| diff --git a/os/rt/include/chdebug.h b/os/rt/include/chdebug.h index 2e4b846f3..a839813d7 100644 --- a/os/rt/include/chdebug.h +++ b/os/rt/include/chdebug.h @@ -192,7 +192,9 @@ typedef struct {  #if !defined(chDbgAssert)
  #if CH_DBG_ENABLE_ASSERTS == TRUE
  #define chDbgAssert(c, r) do {                                              \
 +  /*lint -save -e506 -e774 [2.1, 14.3] Can be a constant.*/                 \
    if (!(c)) {                                                               \
 +  /*lint -restore*/                                                         \
      chSysHalt(__func__);                                                    \
    }                                                                         \
  } while (false)
 diff --git a/os/rt/include/chschd.h b/os/rt/include/chschd.h index c106dd9b0..78fac0004 100644 --- a/os/rt/include/chschd.h +++ b/os/rt/include/chschd.h @@ -617,10 +617,10 @@ static inline void queue_init(threads_queue_t *tqp) {   *
   * @notapi
   */
 -static inline bool queue_isempty(threads_queue_t *tqp) {
 +static inline bool queue_isempty(const threads_queue_t *tqp) {
    /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
 -  return (bool)(tqp->p_next == (thread_t *)tqp);
 +  return (bool)(tqp->p_next == (const thread_t *)tqp);
    /*lint -restore*/
  }
 @@ -632,10 +632,10 @@ static inline bool queue_isempty(threads_queue_t *tqp) {   *
   * @notapi
   */
 -static inline bool queue_notempty(threads_queue_t *tqp) {
 +static inline bool queue_notempty(const threads_queue_t *tqp) {
    /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
 -  return (bool)(tqp->p_next != (thread_t *)tqp);
 +  return (bool)(tqp->p_next != (const thread_t *)tqp);
    /*lint -restore*/
  }
 diff --git a/os/rt/include/chsys.h b/os/rt/include/chsys.h index 88814fa16..af725f627 100644 --- a/os/rt/include/chsys.h +++ b/os/rt/include/chsys.h @@ -28,6 +28,8 @@  #ifndef _CHSYS_H_
  #define _CHSYS_H_
 +/*lint -sem(chSysHalt, r_no)*/
 +
  /*===========================================================================*/
  /* Module constants.                                                         */
  /*===========================================================================*/
 diff --git a/os/rt/include/chthreads.h b/os/rt/include/chthreads.h index 6632d8d62..966f5de08 100644 --- a/os/rt/include/chthreads.h +++ b/os/rt/include/chthreads.h @@ -28,6 +28,8 @@  #ifndef _CHTHREADS_H_
  #define _CHTHREADS_H_
 +/*lint -sem(chThdExit, r_no) -sem(chThdExitS, r_no)*/
 +
  /*===========================================================================*/
  /* Module constants.                                                         */
  /*===========================================================================*/
 diff --git a/os/rt/ports/SIMIA32/chcore.h b/os/rt/ports/SIMIA32/chcore.h index 943dbaf6e..b78463a86 100644 --- a/os/rt/ports/SIMIA32/chcore.h +++ b/os/rt/ports/SIMIA32/chcore.h @@ -368,4 +368,4 @@ static inline void port_wait_for_interrupt(void) {  #endif /* _CHCORE_H_ */
 -/** @} */
 +/** @} */
\ No newline at end of file diff --git a/os/rt/src/chdebug.c b/os/rt/src/chdebug.c index a09f327b4..d13be65b4 100644 --- a/os/rt/src/chdebug.c +++ b/os/rt/src/chdebug.c @@ -280,8 +280,11 @@ void _dbg_trace(thread_t *otp) {    ch.dbg.trace_buffer.tb_ptr->se_tp     = currp;
    ch.dbg.trace_buffer.tb_ptr->se_wtobjp = otp->p_u.wtobjp;
    ch.dbg.trace_buffer.tb_ptr->se_state  = (uint8_t)otp->p_state;
 +  /*lint -save -e946 -e947 [18.2, 18.3] Normal pointers arithmetic, it
 +    is safe.*/
    if (++ch.dbg.trace_buffer.tb_ptr >=
        &ch.dbg.trace_buffer.tb_buffer[CH_DBG_TRACE_BUFFER_SIZE]) {
 +  /*lint -restore*/
      ch.dbg.trace_buffer.tb_ptr = &ch.dbg.trace_buffer.tb_buffer[0];
    }
  }
 diff --git a/os/rt/src/chdynamic.c b/os/rt/src/chdynamic.c index c2fca8534..61044146e 100644 --- a/os/rt/src/chdynamic.c +++ b/os/rt/src/chdynamic.c @@ -92,7 +92,7 @@ void chThdRelease(thread_t *tp) {    trefs_t refs;
    chSysLock();
 -  chDbgAssert(tp->p_refs > 0, "not referenced");
 +  chDbgAssert(tp->p_refs > 0U, "not referenced");
    tp->p_refs--;
    refs = tp->p_refs;
    chSysUnlock();
 diff --git a/os/rt/src/chevents.c b/os/rt/src/chevents.c index e768457f5..df5e4bfaa 100644 --- a/os/rt/src/chevents.c +++ b/os/rt/src/chevents.c @@ -215,7 +215,7 @@ void chEvtBroadcastFlagsI(event_source_t *esp, eventflags_t flags) {    elp = esp->es_next;
    /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
    while (elp != (event_listener_t *)esp) {
 -  /*list -restore*/
 +  /*lint -restore*/
      elp->el_flags |= flags;
      /* When flags == 0 the thread will always be signaled because the
         source does not emit any flag.*/
 diff --git a/os/rt/src/chheap.c b/os/rt/src/chheap.c index 5214462ce..e492d8a52 100644 --- a/os/rt/src/chheap.c +++ b/os/rt/src/chheap.c @@ -48,10 +48,16 @@  #define H_LOCK(h)       chMtxLock(&(h)->h_mtx)
  #define H_UNLOCK(h)     chMtxUnlock(&(h)->h_mtx)
  #else
 -#define H_LOCK(h)       chSemWait(&(h)->h_sem)
 +#define H_LOCK(h)       (void) chSemWait(&(h)->h_sem)
  #define H_UNLOCK(h)     chSemSignal(&(h)->h_sem)
  #endif
 +#define LIMIT(p)                                                            \
 +  /*lint -save -e9087 [11.3] Safe cast.*/                                   \
 +  (union heap_header *)((uint8_t *)(p) +                                    \
 +                        sizeof(union heap_header) + (p)->h.size)            \
 +  /*lint -restore*/
 +
  /*===========================================================================*/
  /* Module exported variables.                                                */
  /*===========================================================================*/
 @@ -85,7 +91,7 @@ static memory_heap_t default_heap;  void _heap_init(void) {
    default_heap.h_provider = chCoreAlloc;
 -  default_heap.h_free.h.u.next = (union heap_header *)NULL;
 +  default_heap.h_free.h.u.next = NULL;
    default_heap.h_free.h.size = 0;
  #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
    chMtxObjectInit(&default_heap.h_mtx);
 @@ -160,7 +166,9 @@ void *chHeapAlloc(memory_heap_t *heapp, size_t size) {        }
        else {
          /* Block bigger enough, must split it.*/
 +        /*lint -save -e9087 [11.3] Safe cast.*/
          fp = (void *)((uint8_t *)(hp) + sizeof(union heap_header) + size);
 +        /*lint -restore*/
          fp->h.u.next = hp->h.u.next;
          fp->h.size = (hp->h.size - sizeof(union heap_header)) - size;
          qp->h.u.next = fp;
 @@ -169,7 +177,9 @@ void *chHeapAlloc(memory_heap_t *heapp, size_t size) {        hp->h.u.heap = heapp;
        H_UNLOCK(heapp);
 +      /*lint -save -e9087 [11.3] Safe cast.*/
        return (void *)(hp + 1);
 +      /*lint -restore*/
      }
      qp = hp;
    }
 @@ -184,17 +194,15 @@ void *chHeapAlloc(memory_heap_t *heapp, size_t size) {        hp->h.size = size;
        hp++;
 +      /*lint -save -e9087 [11.3] Safe cast.*/
        return (void *)hp;
 +      /*lint -restore*/
      }
    }
    return NULL;
  }
 -#define LIMIT(p) (union heap_header *)((uint8_t *)(p) + \
 -                                        sizeof(union heap_header) + \
 -                                        (p)->h.size)
 -
  /**
   * @brief   Frees a previously allocated memory block.
   *
 @@ -208,16 +216,18 @@ void chHeapFree(void *p) {    chDbgCheck(p != NULL);
 +  /*lint -save -e9087 [11.3] Safe cast.*/
    hp = (union heap_header *)p - 1;
 +  /*lint -restore*/
    heapp = hp->h.u.heap;
    qp = &heapp->h_free;
    H_LOCK(heapp);
    while (true) {
 -    chDbgAssert((hp < qp) || (hp >= LIMIT(qp)), "within free block");
 -
      /*lint -save -e946 -e947 [18.2, 18.3] Normal pointers arithmetic, it
        is safe.*/
 +    chDbgAssert((hp < qp) || (hp >= LIMIT(qp)), "within free block");
 +
      if (((qp == &heapp->h_free) || (hp > qp)) &&
          ((qp->h.u.next == NULL) || (hp < qp->h.u.next))) {
      /*lint -restore*/
 @@ -270,6 +280,7 @@ size_t chHeapStatus(memory_heap_t *heapp, size_t *sizep) {    n = 0;
    qp = &heapp->h_free;
    while (qp->h.u.next != NULL) {
 +    sz += qp->h.u.next->h.size;
      n++;
      qp = qp->h.u.next;
    }
 diff --git a/os/rt/src/chmempools.c b/os/rt/src/chmempools.c index e5c656844..bdacedc0d 100644 --- a/os/rt/src/chmempools.c +++ b/os/rt/src/chmempools.c @@ -96,11 +96,13 @@ void chPoolObjectInit(memory_pool_t *mp, size_t size, memgetfunc_t provider) {   */
  void chPoolLoadArray(memory_pool_t *mp, void *p, size_t n) {
 -  chDbgCheck((mp != NULL) && (n != 0));
 +  chDbgCheck((mp != NULL) && (n != 0U));
    while (n != 0U) {
      chPoolAdd(mp, p);
 +    /*lint -save -e9087 [11.3] Safe cast.*/
      p = (void *)(((uint8_t *)p) + mp->mp_object_size);
 +    /*lint -restore*/
      n--;
    }
  }
 diff --git a/os/rt/src/chqueues.c b/os/rt/src/chqueues.c index 33f0df32c..49bf49f24 100644 --- a/os/rt/src/chqueues.c +++ b/os/rt/src/chqueues.c @@ -231,7 +231,7 @@ size_t chIQReadTimeout(input_queue_t *iqp, uint8_t *bp,    qnotify_t nfy = iqp->q_notify;
    size_t r = 0;
 -  chDbgCheck(n > 0);
 +  chDbgCheck(n > 0U);
    chSysLock();
    while (true) {
 @@ -429,7 +429,7 @@ size_t chOQWriteTimeout(output_queue_t *oqp, const uint8_t *bp,    qnotify_t nfy = oqp->q_notify;
    size_t w = 0;
 -  chDbgCheck(n > 0);
 +  chDbgCheck(n > 0U);
    chSysLock();
    while (true) {
 diff --git a/os/rt/src/chregistry.c b/os/rt/src/chregistry.c index 0b5e01681..8a237ab69 100644 --- a/os/rt/src/chregistry.c +++ b/os/rt/src/chregistry.c @@ -164,7 +164,7 @@ thread_t *chRegNextThread(thread_t *tp) {    }
  #if CH_CFG_USE_DYNAMIC == TRUE
    else {
 -    chDbgAssert(ntp->p_refs < 255, "too many references");
 +    chDbgAssert(ntp->p_refs < 255U, "too many references");
      ntp->p_refs++;
    }
  #endif
 diff --git a/os/rt/src/chschd.c b/os/rt/src/chschd.c index 6775b1a12..dacc1b7c1 100644 --- a/os/rt/src/chschd.c +++ b/os/rt/src/chschd.c @@ -87,17 +87,16 @@ void _scheduler_init(void) {   */
  void queue_prio_insert(thread_t *tp, threads_queue_t *tqp) {
 -  /* cp iterates over the queue.*/
 +  /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
    thread_t *cp = (thread_t *)tqp;
    do {
 -    /* Iterate to next thread in queue.*/
      cp = cp->p_next;
 -    /* Not end of queue? and cp has equal or higher priority than tp?.*/
    } while ((cp != (thread_t *)tqp) && (cp->p_prio >= tp->p_prio));
 -  /* Insertion on p_prev.*/
 +  /*lint -restore*/
    tp->p_next = cp;
    tp->p_prev = cp->p_prev;
 -  tp->p_prev->p_next = cp->p_prev = tp;
 +  tp->p_prev->p_next = tp;
 +  cp->p_prev = tp;
  }
  /**
 @@ -110,9 +109,12 @@ void queue_prio_insert(thread_t *tp, threads_queue_t *tqp) {   */
  void queue_insert(thread_t *tp, threads_queue_t *tqp) {
 +  /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
    tp->p_next = (thread_t *)tqp;
 +  /*lint -restore*/
    tp->p_prev = tqp->p_prev;
 -  tp->p_prev->p_next = tqp->p_prev = tp;
 +  tp->p_prev->p_next = tp;
 +  tqp->p_prev = tp;
  }
  /**
 @@ -128,7 +130,10 @@ void queue_insert(thread_t *tp, threads_queue_t *tqp) {  thread_t *queue_fifo_remove(threads_queue_t *tqp) {
    thread_t *tp = tqp->p_next;
 -  (tqp->p_next = tp->p_next)->p_prev = (thread_t *)tqp;
 +  tqp->p_next = tp->p_next;
 +  /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
 +  tqp->p_next->p_prev = (thread_t *)tqp;
 +  /*lint -restore*/
    return tp;
  }
 @@ -146,7 +151,10 @@ thread_t *queue_fifo_remove(threads_queue_t *tqp) {  thread_t *queue_lifo_remove(threads_queue_t *tqp) {
    thread_t *tp = tqp->p_prev;
 -  (tqp->p_prev = tp->p_prev)->p_next = (thread_t *)tqp;
 +  tqp->p_prev = tp->p_prev;
 +  /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
 +  tqp->p_prev->p_next = (thread_t *)tqp;
 +  /*lint -restore*/
    return tp;
  }
 diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c index ee58694bc..b20779fcd 100644 --- a/os/rt/src/chthreads.c +++ b/os/rt/src/chthreads.c @@ -144,8 +144,12 @@ thread_t *_thread_init(thread_t *tp, tprio_t prio) {   */
  void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v) {
 +  /*lint -save -e946 -e947 [18.2, 18.3] Normal pointers arithmetic, it
 +    is safe.*/
    while (startp < endp) {
 -    *startp++ = v;
 +  /*lint -restore*/
 +    *startp = v;
 +    startp++;
    }
  }
  #endif /* CH_DBG_FILL_THREADS */
 @@ -480,7 +484,7 @@ msg_t chThdWait(thread_t *tp) {    chSysLock();
    chDbgAssert(tp != currp, "waiting self");
  #if CH_CFG_USE_DYNAMIC == TRUE
 -  chDbgAssert(tp->p_refs > 0, "not referenced");
 +  chDbgAssert(tp->p_refs > 0U, "not referenced");
  #endif
    if (tp->p_state != CH_STATE_FINAL) {
      list_insert(currp, &tp->p_waiting);
 | 
