]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools/cgsnapshot: use exit code 129 on invalid usage
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Fri, 30 Sep 2022 06:23:57 +0000 (06:23 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 30 Sep 2022 14:34:55 +0000 (08:34 -0600)
The exit code 1 refers to general error and using -1 wraps to
255, both codes do not signify bad arguments. Let's use exit code 129
(EXIT_BADARGS) for hinting to the users about invalid usage.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/tools/cgsnapshot.c

index a17d9f1c922951bb91b956879ac3afe3a520ca08..6d2e8c80c75d0806b047b355763b64d4da9f983d 100644 (file)
@@ -746,7 +746,7 @@ int main(int argc, char *argv[])
                        break;
                default:
                        usage(1, argv[0]);
-                       return -1;
+                       exit(EXIT_BADARGS);
                }
        }
 
@@ -773,14 +773,18 @@ int main(int argc, char *argv[])
                /* load the blacklist from the default location */
                ret  = load_list(BLACKLIST_CONF, &black_list);
        }
-       if (ret != 0)
+       if (ret != 0) {
+               ret = EXIT_BADARGS;
                goto finish;
+       }
 
        /* whitelist */
        if (flags & FL_WHITE)
                ret = load_list(wl_file, &white_list);
-       if (ret != 0)
+       if (ret != 0) {
+               ret = EXIT_BADARGS;
                goto finish;
+       }
 
        /* print the header */
        fprintf(output_f, "# Configuration file generated by cgsnapshot\n");
@@ -793,6 +797,7 @@ int main(int argc, char *argv[])
 
        /* print mount points section */
        ret = parse_mountpoints(wanted_cont, argv[0]);
+       ret = ret ? EXIT_BADARGS : 0;
        /* continue with processing on error*/
 
        /* print hierarchies section */