X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fdetect-virt%2Fdetect-virt.c;h=9a924117db64f5f8a8463318bcc181de329c5bf1;hb=ac6e2f0dfc2e800f01c79ecea2b811914110a7b9;hp=8cf8dcfabc08b6262fc111deb2b5af71457e8d41;hpb=248fab742d2b61557de93ac6e422986a8858bf52;p=elogind.git diff --git a/src/detect-virt/detect-virt.c b/src/detect-virt/detect-virt.c index 8cf8dcfab..9a924117d 100644 --- a/src/detect-virt/detect-virt.c +++ b/src/detect-virt/detect-virt.c @@ -36,18 +36,15 @@ static enum { ONLY_CONTAINER } arg_mode = ANY_VIRTUALIZATION; -static int help(void) { - +static void help(void) { printf("%s [OPTIONS...]\n\n" "Detect execution in a virtualized environment.\n\n" " -h --help Show this help\n" " --version Show package version\n" " -c --container Only detect whether we are run in a container\n" " -v --vm Only detect whether we are run in a VM\n" - " -q --quiet Don't output anything, just set return value\n", - program_invocation_short_name); - - return 0; + " -q --quiet Don't output anything, just set return value\n" + , program_invocation_short_name); } static int parse_argv(int argc, char *argv[]) { @@ -70,12 +67,13 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "hqcv", options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "hqcv", options, NULL)) >= 0) switch (c) { case 'h': - return help(); + help(); + return 0; case ARG_VERSION: puts(PACKAGE_STRING); @@ -100,10 +98,10 @@ static int parse_argv(int argc, char *argv[]) { default: assert_not_reached("Unhandled option"); } - } if (optind < argc) { - help(); + log_error("%s takes no arguments.", + program_invocation_short_name); return -EINVAL; } @@ -133,7 +131,7 @@ int main(int argc, char *argv[]) { v = detect_virtualization(&id); if (v < 0) { - log_error("Failed to check for virtualization: %s", strerror(-v)); + log_error_errno(v, "Failed to check for virtualization: %m"); return EXIT_FAILURE; } @@ -144,7 +142,7 @@ int main(int argc, char *argv[]) { case ONLY_CONTAINER: r = detect_container(&id); if (r < 0) { - log_error("Failed to check for container: %s", strerror(-r)); + log_error_errno(r, "Failed to check for container: %m"); return EXIT_FAILURE; } @@ -154,7 +152,7 @@ int main(int argc, char *argv[]) { case ONLY_VM: r = detect_vm(&id); if (r < 0) { - log_error("Failed to check for vm: %s", strerror(-r)); + log_error_errno(r, "Failed to check for vm: %m"); return EXIT_FAILURE; }