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 <gthe...@google.com>
---
 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@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Reply via email to