X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fudevadm-test-builtin.c;h=b2a7376292c311113f1cd8c199788e611921681c;hb=ea6ec096db5f9f3562b9bbf438da7fe21411c74d;hp=f4aa21ee72fcc95fcd8d185ca0d68a63bd22fec6;hpb=d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3d;p=elogind.git diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c index f4aa21ee7..b2a737629 100644 --- a/src/udev/udevadm-test-builtin.c +++ b/src/udev/udevadm-test-builtin.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -34,16 +33,18 @@ #include "udev.h" -static void help(struct udev *udev) -{ - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: udevadm builtin [--help] \n"); +static void help(struct udev *udev) { + printf("%s builtin [--help] COMMAND SYSPATH\n\n" + "Test a built-in command.\n\n" + " -h --help Print this message\n" + " --version Print version of the program\n\n" + "Commands:\n" + , program_invocation_short_name); + udev_builtin_list(udev); - fprintf(stderr, "\n"); } -static int adm_builtin(struct udev *udev, int argc, char *argv[]) -{ +static int adm_builtin(struct udev *udev, int argc, char *argv[]) { static const struct option options[] = { { "help", no_argument, NULL, 'h' }, {} @@ -53,21 +54,14 @@ static int adm_builtin(struct udev *udev, int argc, char *argv[]) char filename[UTIL_PATH_SIZE]; struct udev_device *dev = NULL; enum udev_builtin_cmd cmd; - int rc = EXIT_SUCCESS; - - for (;;) { - int option; + int rc = EXIT_SUCCESS, c; - option = getopt_long(argc, argv, "h", options, NULL); - if (option == -1) - break; - - switch (option) { + while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) + switch (c) { case 'h': help(udev); goto out; } - } command = argv[optind++]; if (command == NULL) { @@ -79,7 +73,7 @@ static int adm_builtin(struct udev *udev, int argc, char *argv[]) syspath = argv[optind++]; if (syspath == NULL) { - fprintf(stderr, "syspath missing\n\n"); + fprintf(stderr, "syspath missing\n"); rc = 3; goto out; } @@ -122,6 +116,6 @@ out: const struct udevadm_cmd udevadm_test_builtin = { .name = "test-builtin", .cmd = adm_builtin, - .help = "test a built-in command", + .help = "Test a built-in command", .debug = true, };