On Thu, Aug 11, 2011 at 9:02 AM, Jan Safranek <jsafr...@redhat.com> wrote:
>
> When parse_mountpoints() fails, the error is not propagated to final
> cgsnapshot exit code. Also free black&white lists on error.
>
> Signed-off-by: Jan Safranek <jsafr...@redhat.com>
> ---
>
>  src/tools/cgsnapshot.c |   20 +++++++++++---------
>  1 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/src/tools/cgsnapshot.c b/src/tools/cgsnapshot.c
> index 1247488..4a6a8c8 100644
> --- a/src/tools/cgsnapshot.c
> +++ b/src/tools/cgsnapshot.c
> @@ -693,7 +693,7 @@ static int parse_mountpoints(cont_name_t 
> cont_names[CG_CONTROLLER_MAX],
>
>  int main(int argc, char *argv[])
>  {
> -       int ret = 0;
> +       int ret = 0, err;
>        int c;
>
>        int i;
> @@ -777,36 +777,38 @@ int main(int argc, char *argv[])
>                ret  = load_list(BLACKLIST_CONF, &black_list);
>        }
>        if (ret != 0)
> -               return ret;
> +               goto finish;
>
>        /* whitelist */
>        if (flags & FL_WHITE)
>                ret = load_list(wl_file, &white_list);
>        if (ret != 0)
> -               return ret;
> +               goto finish;
>
>        /* print the header */
>        fprintf(of, "# Configuration file generated by cgsnapshot\n");
>
>        /* initialize libcgroup */
>        ret = cgroup_init();
> -
> -       if (ret) {
> +       if (ret)
>                /* empty configuration file */
> -               return ret;
> -       }
> +               goto finish;
>
>        /* print mount points section */
>        ret = parse_mountpoints(wanted_cont, argv[0]);
> +       /* continue with processing on error*/
>
>        /* print hierarchies section */
> -       ret = parse_controllers(wanted_cont, argv[0]);
> +       /*replace error from parse_mountpoints() only with another error*/
> +       err = parse_controllers(wanted_cont, argv[0]);
> +       if (err)
> +               ret = err;
>
> +finish:
>        free_list(black_list);
>        free_list(white_list);
>
>        if (of != stdout)
>                fclose(of);
> -

random whitespace?

>
>        return ret;
>  }
>
>

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to