]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
cgsnapshot: fixed exit codes when parsing of mountpoints fails
authorJan Safranek <jsafrane@redhat.com>
Wed, 24 Aug 2011 09:39:33 +0000 (11:39 +0200)
committerJan Safranek <jsafrane@redhat.com>
Wed, 14 Sep 2011 11:20:54 +0000 (13:20 +0200)
When parse_mountpoints() fails, the error is not propagated to final
cgsnapshot exit code. Also free black&white lists on error.

Changelog:
  - remove whitespace changes

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
src/tools/cgsnapshot.c

index 12474881709177d03a61ece05716ef7255983b8f..7359779ed0ab79cef22454b02d1a9ddc70089a17 100644 (file)
@@ -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,31 +777,34 @@ 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);