[rtems commit] posix/src/mutexinit.c: Fix used before initialized warning

Joel Sherrill joel at rtems.org
Wed Apr 26 14:05:30 UTC 2017


On Tue, Apr 25, 2017 at 7:59 PM, Joel Sherrill <joel at rtems.org> wrote:

>
>
> On Tue, Apr 25, 2017 at 7:25 PM, Gedare Bloom <gedare at rtems.org> wrote:
>
>> On Tue, Apr 25, 2017 at 7:14 PM, Joel Sherrill <joel at rtems.org> wrote:
>> > Module:    rtems
>> > Branch:    master
>> > Commit:    6601684f74f0ea1ec44fb52ec75d52215af11f5f
>> > Changeset: http://git.rtems.org/rtems/commit/?id=6601684f74f0ea1ec44fb5
>> 2ec75d52215af11f5f
>> >
>> > Author:    Joel Sherrill <joel at rtems.org>
>> > Date:      Tue Apr 25 13:57:03 2017 -0500
>> >
>> > posix/src/mutexinit.c: Fix used before initialized warning
>> >
>> > ---
>> >
>> >  cpukit/posix/src/mutexinit.c | 3 +++
>> >  1 file changed, 3 insertions(+)
>> >
>> > diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c
>> > index 39139a4..47e0bcb 100644
>> > --- a/cpukit/posix/src/mutexinit.c
>> > +++ b/cpukit/posix/src/mutexinit.c
>> > @@ -40,6 +40,9 @@ int pthread_mutex_init(
>> >    const Scheduler_Control   *scheduler;
>> >    Priority_Control           priority;
>> >
>> > +  /* initialize to avoid warning for used uninitialized */
>> > +  priority = 0;
>> > +
>> The warning is spurious. You could refactor the code so the compiler
>> doesn't get confused.
>>
>
> If you see how to do it, please go ahead. I have looked into this multiple
> times over the years and not found the magic.
>
>
>

I have a proposal for this. It does involve moving some of the error
checking inside the object allocator critical section.

Wait for a patch. I need to test it.


>
>> >    if ( attr ) the_attr = attr;
>> >    else        the_attr = &_POSIX_Mutex_Default_attributes;
>> >
>> >
>> > _______________________________________________
>> > vc mailing list
>> > vc at rtems.org
>> > http://lists.rtems.org/mailman/listinfo/vc
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20170426/195c7233/attachment.html>


More information about the devel mailing list