<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 26, 2017 at 9:02 PM, Gedare Bloom <span dir="ltr"><<a href="mailto:gedare@rtems.org" target="_blank">gedare@rtems.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I might rather see the switch refactored to an if-then block, since it<br>
has quite a bit of structure to it now.<br>
<div><div class="h5"><br></div></div></blockquote><div><br></div><div>How about it includes all cases?</div><div><br></div><div>--joel</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
On Wed, Apr 26, 2017 at 4:42 PM, Joel Sherrill <<a href="mailto:joel@rtems.org">joel@rtems.org</a>> wrote:<br>
> ---<br>
>  cpukit/posix/src/mutexinit.c | 41 +++++++++++++++++++-----------<wbr>-----------<br>
>  1 file changed, 19 insertions(+), 22 deletions(-)<br>
><br>
> diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c<br>
> index 47e0bcb..cdbba11 100644<br>
> --- a/cpukit/posix/src/mutexinit.c<br>
> +++ b/cpukit/posix/src/mutexinit.c<br>
> @@ -38,10 +38,6 @@ int pthread_mutex_init(<br>
>    const pthread_mutexattr_t *the_attr;<br>
>    POSIX_Mutex_Protocol       protocol;<br>
>    const Scheduler_Control   *scheduler;<br>
> -  Priority_Control           priority;<br>
> -<br>
> -  /* initialize to avoid warning for used uninitialized */<br>
> -  priority = 0;<br>
><br>
>    if ( attr ) the_attr = attr;<br>
>    else        the_attr = &_POSIX_Mutex_Default_<wbr>attributes;<br>
> @@ -109,23 +105,6 @@ int pthread_mutex_init(<br>
>    }<br>
>  #endif<br>
><br>
> -  if ( protocol == POSIX_MUTEX_PRIORITY_CEILING ) {<br>
> -    int  prio_ceiling;<br>
> -    bool valid;<br>
> -<br>
> -    scheduler = _Thread_Scheduler_get_home( _Thread_Get_executing() );<br>
> -    prio_ceiling = the_attr->prio_ceiling;<br>
> -<br>
> -    if ( prio_ceiling == INT_MAX ) {<br>
> -      prio_ceiling = _POSIX_Priority_Get_maximum( scheduler );<br>
> -    }<br>
> -<br>
> -    priority = _POSIX_Priority_To_core( scheduler, prio_ceiling, &valid );<br>
> -    if ( !valid ) {<br>
> -      return EINVAL;<br>
> -    }<br>
> -  }<br>
> -<br>
>    the_mutex = _POSIX_Mutex_Allocate();<br>
><br>
>    if ( !the_mutex ) {<br>
> @@ -137,9 +116,27 @@ int pthread_mutex_init(<br>
>    the_mutex->is_recursive = ( the_attr->type == PTHREAD_MUTEX_RECURSIVE );<br>
><br>
>    switch ( protocol ) {<br>
> -    case POSIX_MUTEX_PRIORITY_CEILING:<br>
> +    case POSIX_MUTEX_PRIORITY_CEILING: {<br>
> +      int               prio_ceiling;<br>
> +      bool              valid;<br>
> +      Priority_Control  priority;<br>
> +<br>
> +      scheduler = _Thread_Scheduler_get_home( _Thread_Get_executing() );<br>
> +      prio_ceiling = the_attr->prio_ceiling;<br>
> +<br>
> +      if ( prio_ceiling == INT_MAX ) {<br>
> +       prio_ceiling = _POSIX_Priority_Get_maximum( scheduler );<br>
> +      }<br>
> +<br>
> +      priority = _POSIX_Priority_To_core( scheduler, prio_ceiling, &valid );<br>
> +      if ( !valid ) {<br>
> +        _POSIX_Mutex_Free(the_mutex);<br>
> +        _Objects_Allocator_unlock();<br>
> +       return EINVAL;<br>
> +      }<br>
>        _CORE_ceiling_mutex_<wbr>Initialize( &the_mutex->Mutex, scheduler, priority );<br>
>        break;<br>
> +    }<br>
>      default:<br>
>        _Assert(<br>
>          the_mutex->protocol == POSIX_MUTEX_NO_PROTOCOL<br>
> --<br>
> 1.8.3.1<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
</blockquote></div><br></div></div>