IAR compiler warning, with suggested fix Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
cipher
Posts: 24
Joined: Tue May 31, 2016 10:05 pm
Has thanked: 2 times
Been thanked: 2 times

IAR compiler warning, with suggested fix  Topic is solved

Postby cipher » Sat Jun 04, 2016 5:41 pm

Hi Giovanni
Just noticed I'm getting the following warning when compiling ChibiOS/RT under IAR 7.60.1

Code: Select all

Warning[Pe188]: enumerated type mixed with another type ChibiOS\os\rt\ports\ARMCMx\cmsis_os\cmsis_os.h 505


I suggest to change the original code

Code: Select all

/**
 * @brief   Returns priority of a thread.
 */
static inline osPriority osThreadGetPriority(osThreadId thread_id) {

  return thread_id->p_prio;
}


to

Code: Select all

/**
 * @brief   Returns priority of a thread.
 */
static inline osPriority osThreadGetPriority(osThreadId thread_id) {

  return (osPriority)thread_id->p_prio;
}


This will clean this up

Just trying to be helpful :-)

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: IAR compiler warning, with suggested fix

Postby Giovanni » Sat Jun 04, 2016 5:59 pm

Hi,

Thanks, there is also another problem, it should be:

Code: Select all

/**
 * @brief   Returns priority of a thread.
 */
static inline osPriority osThreadGetPriority(osThreadId thread_id) {

  return (osPriority)(NORMALPRIO - thread_id->p_prio);
}


Fixed.

Giovanni

cipher
Posts: 24
Joined: Tue May 31, 2016 10:05 pm
Has thanked: 2 times
Been thanked: 2 times

Re: IAR compiler warning, with suggested fix

Postby cipher » Sat Jun 04, 2016 8:29 pm

Glad to help

Also noticed another one:

Code: Select all

Warning[Pe188]: enumerated type mixed with another type ChibiOS\os\rt\ports\ARMCMx\cmsis_os\cmsis_os.c 204


Code: Select all

/**
 * @brief   Change thread priority.
 * @note    This can interfere with the priority inheritance mechanism.
 */
osStatus osThreadSetPriority(osThreadId thread_id, osPriority newprio) {
  osPriority oldprio;
  thread_t * tp = (thread_t *)thread_id;

  chSysLock();

  /* Changing priority.*/
#if CH_CFG_USE_MUTEXES
  oldprio = (osPriority)tp->p_realprio;
  if ((tp->p_prio == tp->p_realprio) || ((tprio_t)newprio > tp->p_prio))
    tp->p_prio = (tprio_t)newprio;
  tp->p_realprio = (tprio_t)newprio;
#else
  oldprio = tp->p_prio;
  tp->p_prio = (tprio_t)newprio;
#endif

  /* The following states need priority queues reordering.*/
  switch (tp->p_state) {
#if CH_CFG_USE_MUTEXES |                                                    \
    CH_CFG_USE_CONDVARS |                                                   \
    (CH_CFG_USE_SEMAPHORES && CH_CFG_USE_SEMAPHORES_PRIORITY) |             \
    (CH_CFG_USE_MESSAGES && CH_CFG_USE_MESSAGES_PRIORITY)
#if CH_CFG_USE_MUTEXES
  case CH_STATE_WTMTX:
#endif
#if CH_CFG_USE_CONDVARS
  case CH_STATE_WTCOND:
#endif
#if CH_CFG_USE_SEMAPHORES && CH_CFG_USE_SEMAPHORES_PRIORITY
  case CH_STATE_WTSEM:
#endif
#if CH_CFG_USE_MESSAGES && CH_CFG_USE_MESSAGES_PRIORITY
  case CH_STATE_SNDMSGQ:
#endif
    /* Re-enqueues tp with its new priority on the queue.*/
    queue_prio_insert(queue_dequeue(tp),
                      (threads_queue_t *)tp->p_u.wtobjp);
    break;
#endif
  case CH_STATE_READY:
#if CH_DBG_ENABLE_ASSERTS
    /* Prevents an assertion in chSchReadyI().*/
    tp->p_state = CH_STATE_CURRENT;
#endif
    /* Re-enqueues tp with its new priority on the ready list.*/
    chSchReadyI(queue_dequeue(tp));
    break;
  }

  /* Rescheduling.*/
  chSchRescheduleS();

  chSysUnlock();

  return oldprio;
}



The issue is that the function prototype returns osStatus but the return variable is of type osPriority


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 15 guests