[haiku-commits] r40232 - haiku/branches/developer/bonefish/signals/src/system/kernel

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 13 Jan 2011 20:46:15 +0100 (CET)

Author: bonefish
Date: 2011-01-13 20:46:15 +0100 (Thu, 13 Jan 2011)
New Revision: 40232
Changeset: http://dev.haiku-os.org/changeset/40232

Modified:
   haiku/branches/developer/bonefish/signals/src/system/kernel/image.cpp
Log:
_get_next_image_info(): Simplified using Team::Get().


Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/image.cpp
===================================================================
--- haiku/branches/developer/bonefish/signals/src/system/kernel/image.cpp       
2011-01-13 19:41:01 UTC (rev 40231)
+++ haiku/branches/developer/bonefish/signals/src/system/kernel/image.cpp       
2011-01-13 19:46:15 UTC (rev 40232)
@@ -217,45 +217,29 @@
        if (size > sizeof(image_info))
                return B_BAD_VALUE;
 
-       status_t status = B_ENTRY_NOT_FOUND;
-       Team *team;
-       cpu_status state;
+       // get the team
+       Team* team = Team::Get(teamID);
+       if (team == NULL)
+               return B_BAD_TEAM_ID;
+       BReference<Team> teamReference(team, true);
 
-       mutex_lock(&sImageMutex);
+       // iterate through the team's images
+       MutexLocker imageLocker(sImageMutex);
 
-       state = disable_interrupts();
-       GRAB_TEAM_LOCK();
+       struct image* image = NULL;
+       int32 count = 0;
 
-       if (teamID == B_CURRENT_TEAM)
-               team = thread_get_current_thread()->team;
-       else if (teamID == B_SYSTEM_TEAM)
-               team = team_get_kernel_team();
-       else
-               team = team_get_team_struct_locked(teamID);
-
-       if (team) {
-               struct image *image = NULL;
-               int32 count = 0;
-
-               while ((image = (struct 
image*)list_get_next_item(&team->image_list,
-                               image)) != NULL) {
-                       if (count == *cookie) {
-                               memcpy(info, &image->info, size);
-                               status = B_OK;
-                               (*cookie)++;
-                               break;
-                       }
-                       count++;
+       while ((image = (struct image*)list_get_next_item(&team->image_list,
+                       image)) != NULL) {
+               if (count == *cookie) {
+                       memcpy(info, &image->info, size);
+                       (*cookie)++;
+                       return B_OK;
                }
-       } else
-               status = B_BAD_TEAM_ID;
+               count++;
+       }
 
-       RELEASE_TEAM_LOCK();
-       restore_interrupts(state);
-
-       mutex_unlock(&sImageMutex);
-
-       return status;
+       return B_ENTRY_NOT_FOUND;
 }
 
 


Other related posts:

  • » [haiku-commits] r40232 - haiku/branches/developer/bonefish/signals/src/system/kernel - ingo_weinhold