[PATCH 2/4] refactor task_to_pid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



task_to_pid and task_to_context both scan the set of tasks.
Simplify the code by refactoring task_to_pid to use task_to_context.
No functional change.

Signed-off-by: Greg Thelen <gthelen@xxxxxxxxxx>
---
 task.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/task.c b/task.c
index 51aa2a255326..82fa015805cb 100644
--- a/task.c
+++ b/task.c
@@ -4618,15 +4618,12 @@ pid_to_task(ulong pid)
 ulong
 task_to_pid(ulong task)
 {
-        int i;
         struct task_context *tc;
 
-        
-        tc = FIRST_CONTEXT();
-        for (i = 0; i < RUNNING_TASKS(); i++, tc++) 
-                if (tc->task == task)
-                        return(tc->pid);
-        
+	tc = task_to_context(task);
+	if (tc != NULL)
+		return tc->pid;
+
         return(NO_PID);
 }
 
-- 
2.17.0.484.g0c8726318c-goog

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility



[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux