]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ovs-vsctl: simply vsctl_parent_process_info()
authorAndy Zhou <azhou@ovn.org>
Thu, 4 Aug 2016 18:12:49 +0000 (11:12 -0700)
committerAndy Zhou <azhou@ovn.org>
Wed, 10 Aug 2016 18:29:27 +0000 (11:29 -0700)
Use ds_get_line() instead of hand rolling it. Rearrange the logic
to removes some duplication.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
utilities/ovs-vsctl.c

index efdfb86e67828c6feee4f6abef2a433698ec17b2..e7100954a433cb4d9f4987a3bd19ab97e8ac162c 100644 (file)
@@ -2488,26 +2488,16 @@ vsctl_parent_process_info(void)
         procfile = xasprintf("/proc/%d/cmdline", parent_pid);
 
         f = fopen(procfile, "r");
-        if (!f) {
-            free(procfile);
-            return NULL;
-        }
         free(procfile);
-
-        for (;;) {
-            int c = getc(f);
-            if (!c || c == EOF) {
-            break;
-            }
-            ds_put_char(&s, c);
+        if (f) {
+            ds_get_line(&s, f);
+            fclose(f);
         }
-        fclose(f);
     } else {
         ds_put_cstr(&s, "init");
     }
 
     ds_put_format(&s, " (pid %d)", parent_pid);
-
     return ds_steal_cstr(&s);
 #else
     return NULL;