Kernel/threads - (minor) Clean up code (remove pre C99 constructs)
[tpg/acess2.git] / KernelLand / Kernel / threads.c
index 12613a2..8762a7c 100644 (file)
@@ -355,7 +355,7 @@ tThread *Threads_CloneTCB(Uint Flags)
        if(Flags & CLONE_VM) {
                tProcess        *newproc, *oldproc;
                oldproc = cur->Process;
-               new->Process = malloc( sizeof(struct sProcess) );
+               new->Process = calloc( sizeof(struct sProcess), 1 );
                newproc = new->Process;
                newproc->PID = new->TID;
                if( Flags & CLONE_PGID )
@@ -783,9 +783,13 @@ int Threads_int_Sleep(enum eThreadStatus Status, void *Ptr, int Num, tThread **L
                }
                *ListTail = us;
        }
-       else {
+       else if( ListHead ) {
+               us->Next = *ListHead;
                *ListHead = us;
        }
+       else {
+               // Nothing
+       }
        
        //if( Proc_ThreadSync(us) )
        //      return ;
@@ -1310,22 +1314,16 @@ void Threads_int_DumpThread(tThread *thread)
  */
 void Threads_DumpActive(void)
 {
-       tThread *thread;
-       tThreadList     *list;
-       #if SCHEDULER_TYPE == SCHED_RR_PRI
-        int    i;
-       #endif
-       
        Log("Active Threads: (%i reported)", giNumActiveThreads);
        
        #if SCHEDULER_TYPE == SCHED_RR_PRI
-       for( i = 0; i < MIN_PRIORITY+1; i++ )
+       for( int i = 0; i < MIN_PRIORITY+1; i++ )
        {
-               list = &gaActiveThreads[i];
+               tThreadList *list = &gaActiveThreads[i];
        #else
-               list = &gActiveThreads;
+               tThreadList *list = &gActiveThreads;
        #endif
-               for(thread=list->Head;thread;thread=thread->Next)
+               for(tThread *thread = list->Head; thread; thread = thread->Next)
                {
                        Threads_int_DumpThread(thread);
                        if(thread->Status != THREAD_STAT_ACTIVE)

UCC git Repository :: git.ucc.asn.au