]> granicus.if.org Git - procps-ng/commitdiff
redhat analysis: proc/readproc
authorJim Warner <james.warner@comcast.net>
Thu, 6 Oct 2011 13:34:26 +0000 (08:34 -0500)
committerSami Kerola <kerolasa@iki.fi>
Sat, 15 Oct 2011 06:26:27 +0000 (08:26 +0200)
proc/readproc.c

index 4949704e4debcb8853b7298614c7da32a048e5b6..45ec4150b3a79de047ac41e6a0b71884f09e45f8 100644 (file)
@@ -1112,15 +1112,13 @@ next_proc:
     }
 
 next_task:
-    for (;;) {
-        // fills in our path, plus x->tid and x->tgid
-        if ((!(PT->taskfinder(PT,&skel_p,x,path)))         // simple_nexttid
-        || (!(ret = PT->taskreader(PT,new_p,x,path)))) {   // simple_readtask
-            goto next_proc;
-        }
-        if (!new_p) new_p = ret;
-        return ret;
+    // fills in our path, plus x->tid and x->tgid
+    if ((!(PT->taskfinder(PT,&skel_p,x,path)))             // simple_nexttid
+    || (!(ret = PT->taskreader(PT,new_p,x,path)))) {       // simple_readtask
+        goto next_proc;
     }
+    if (!new_p) new_p = ret;
+    return ret;
 
 end_procs:
     if (!saved_x) free(x);
@@ -1152,7 +1150,7 @@ PROCTAB* openproc(int flags, ...) {
       PT->finder = listed_nextpid;
     }else{
       PT->procfs = opendir("/proc");
-      if(!PT->procfs) return NULL;
+      if(!PT->procfs) { free(PT); return NULL; }
       PT->finder = simple_nextpid;
     }
     PT->flags = flags;