#1942 closed defect (fixed)

cpukit/score/src/schedulercbsdetachthread.c: 'sched_info' may be used uninitialized

Reported by: Ralf Corsepius Owned by: Ralf Corsepius
Priority: normal Milestone: 4.11
Component: score Version: 4.11
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

I am facing this warning:
...
cpukit/score/src/schedulercbsdetachthread.c:28:29: warning: 'sched_info' may be used uninitialized in this function
...

Checking cpukit/score/src/schedulercbsdetachthread.c, this warning seems justified to me:
...

Scheduler_CBS_Per_thread *sched_info;

...

if ( the_thread ) {

_Thread_Enable_dispatch();
sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;

}

if ( server_id < 0
server_id >= _Scheduler_CBS_Maximum_servers )

return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;

if ( !the_thread )

return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;

/* Server is not valid. */
if ( !_Scheduler_CBS_Server_list[server_id] )

return SCHEDULER_CBS_ERROR_NOSERVER;

/* Thread and server are not attached. */
if ( _Scheduler_CBS_Server_list[server_id]->task_id != task_id )

return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;

_Scheduler_CBS_Server_list[server_id]->task_id = -1;
sched_info->cbs_server = NULL;

...

I am not sufficiently familiar with this code to be sure, but I think (presuming sched_info is guaranteed to be != NULL), the code could be reorderd into
...

if ( the_thread ) {

_Thread_Enable_dispatch();

}
from above?

sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
sched_info->cbs_server = NULL;

...

Attachments (1)

diff (1021 bytes) - added by Ralf Corsepius on Oct 24, 2011 at 11:56:13 AM.
Patch supposed to resolve issue

Download all attachments as: .zip

Change History (4)

Changed on Oct 24, 2011 at 11:56:13 AM by Ralf Corsepius

Attachment: diff added

Patch supposed to resolve issue

comment:1 Changed on Oct 24, 2011 at 11:56:13 AM by Ralf Corsepius

Owner: changed from Joel Sherrill to Ralf Corsepius
Status: newassigned

comment:2 Changed on Oct 24, 2011 at 11:56:58 AM by Ralf Corsepius

Resolution: fixed
Status: assignedclosed

Patch applied, closing.

comment:3 Changed on Nov 24, 2014 at 6:58:28 PM by Gedare Bloom

Version: HEAD4.11

Replace Version=HEAD with Version=4.11 for the tickets with Milestone >= 4.11

Note: See TracTickets for help on using tickets.