[PATCH] pstree: New applet, v2

Denys Vlasenko vda.linux at googlemail.com
Sat Nov 6 20:21:21 UTC 2010


On Sat, Nov 6, 2010 at 6:06 PM, Lauri Kasanen <curaga at operamail.com> wrote:
> Really attach the patch...

read_proc() is still badly indented.



+       if ((pid = (pid_t) atoi(de->d_name)) != 0) {
+         path = xasprintf("%s/%d/stat", PROC_BASE, pid);
+         if ((file = fopen(path, "r")) != NULL) {

Please do not assign in the if(). This fragment should look like this:

    pid = atoi(de->d_name);
    if (pid != 0) {
        path = xasprintf("%s/%d/stat", PROC_BASE, pid);
        file = fopen_for_read(path);
        if (file != NULL) {

BTW: xasprintf("%s/%d/stat", PROC_BASE, pid);
may be bigger than xasprintf(PROC_BASE"/%d/stat", pid);

-- 
vda


More information about the busybox mailing list