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[]) {
{ "container", no_argument, NULL, 'c' },
{ "vm", optional_argument, NULL, 'v' },
{ "quiet", no_argument, NULL, 'q' },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
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) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
- }
if (optind < argc) {
- help();
+ log_error("%s takes no arguments.",
+ program_invocation_short_name);
return -EINVAL;
}
int main(int argc, char *argv[]) {
const char *id = NULL;
- int r;
int retval = EXIT_SUCCESS;
+ int r;
/* This is mostly intended to be used for scripts which want
* to detect whether we are being run in a virtualized
switch (arg_mode) {
case ANY_VIRTUALIZATION: {
- Virtualization v;
+ int v;
v = detect_virtualization(&id);
if (v < 0) {