Thanks for making this code much more clean. I've tested it and no problem.

Acked-by: William Tu <u9012...@gmail.com>



On Tue, Aug 9, 2016 at 12:50 PM, Andy Zhou <az...@ovn.org> wrote:
> Use ds_get_line() instead of hand rolling it. Rearrange the logic
> to removes some duplication.
>
> Signed-off-by: Andy Zhou <az...@ovn.org>
>
> ---
> v1->v2:  rebase to current master.
> ---
>  utilities/ovs-vsctl.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
> index efdfb86..e710095 100644
> --- a/utilities/ovs-vsctl.c
> +++ b/utilities/ovs-vsctl.c
> @@ -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;
> --
> 1.9.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to