Changeset c16d45a5 in rtems


Ignore:
Timestamp:
Apr 26, 2017, 8:42:09 PM (3 years ago)
Author:
Joel Sherrill <joel@…>
Branches:
master
Children:
12f9c5b7
Parents:
61568e6
Message:

posix/src/mutexinit.c: Reorder to make priority a scoped variable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/mutexinit.c

    r61568e6 rc16d45a5  
    3939  POSIX_Mutex_Protocol       protocol;
    4040  const Scheduler_Control   *scheduler;
    41   Priority_Control           priority;
    42 
    43   /* initialize to avoid warning for used uninitialized */
    44   priority = 0;
    4541
    4642  if ( attr ) the_attr = attr;
     
    110106#endif
    111107
    112   if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
    113     int  prio_ceiling;
    114     bool valid;
    115 
    116     scheduler = _Thread_Scheduler_get_home( _Thread_Get_executing() );
    117     prio_ceiling = the_attr->prio_ceiling;
    118 
    119     if ( prio_ceiling == INT_MAX ) {
    120       prio_ceiling = _POSIX_Priority_Get_maximum( scheduler );
    121     }
    122 
    123     priority = _POSIX_Priority_To_core( scheduler, prio_ceiling, &valid );
    124     if ( !valid ) {
    125       return EINVAL;
    126     }
    127   }
    128 
    129108  the_mutex = _POSIX_Mutex_Allocate();
    130109
     
    138117
    139118  switch ( protocol ) {
    140     case POSIX_MUTEX_PRIORITY_CEILING:
     119    case POSIX_MUTEX_PRIORITY_CEILING: {
     120      int               prio_ceiling;
     121      bool              valid;
     122      Priority_Control  priority;
     123
     124      scheduler = _Thread_Scheduler_get_home( _Thread_Get_executing() );
     125      prio_ceiling = the_attr->prio_ceiling;
     126
     127      if ( prio_ceiling == INT_MAX ) {
     128        prio_ceiling = _POSIX_Priority_Get_maximum( scheduler );
     129      }
     130
     131      priority = _POSIX_Priority_To_core( scheduler, prio_ceiling, &valid );
     132      if ( !valid ) {
     133        _POSIX_Mutex_Free(the_mutex);
     134        _Objects_Allocator_unlock();
     135        return EINVAL;
     136      }
    141137      _CORE_ceiling_mutex_Initialize( &the_mutex->Mutex, scheduler, priority );
    142138      break;
     139    }
    143140    default:
    144141      _Assert(
Note: See TracChangeset for help on using the changeset viewer.