[Bug 1942] New: cpukit/score/src/schedulercbsdetachthread.c: 'sched_info' may be used uninitialized

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Sun Oct 23 05:52:03 UTC 2011


https://www.rtems.org/bugzilla/show_bug.cgi?id=1942

           Summary: cpukit/score/src/schedulercbsdetachthread.c:
                    'sched_info' may be used uninitialized
           Product: RTEMS
           Version: HEAD
          Platform: All
        OS/Version: RTEMS
            Status: NEW
          Severity: normal
          Priority: P3
         Component: cpukit
        AssignedTo: joel.sherrill at oarcorp.com
        ReportedBy: ralf.corsepius at rtems.org


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();
    }
    ["if ... return block" from above]

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

-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the bugs mailing list