X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fudevadm-control.c;h=78170463b6536d1f926bf772565af7ca07c180ad;hb=e530ed5e1407e0571afc01552e41365ffb01befa;hp=00a909fc3171ed1c1a0af14b84bef65aa20ed1d9;hpb=7643ac9a8add1f07ffc237c054feb443b5612717;p=elogind.git diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c index 00a909fc3..78170463b 100644 --- a/src/udev/udevadm-control.c +++ b/src/udev/udevadm-control.c @@ -12,7 +12,6 @@ * GNU General Public License for more details. */ -#include #include #include #include @@ -20,30 +19,28 @@ #include #include #include -#include -#include -#include -#include #include "udev.h" +#include "udev-util.h" -static void print_help(void) -{ - printf("Usage: udevadm control COMMAND\n" - " -e,--exit instruct the daemon to cleanup and exit\n" - " -l,--log-priority=LEVEL set the udev log level for the daemon\n" - " -s,--stop-exec-queue do not execute events, queue only\n" - " -S,--start-exec-queue execute events, flush queue\n" - " -R,--reload reload rules and databases\n" - " -p,--property=KEY=VALUE set a global property for all events\n" - " -m,--children-max=N maximum number of children\n" - " --timeout=SECONDS maximum time to block for a reply\n" - " -h,--help print this help text\n\n"); +static void print_help(void) { + printf("%s control COMMAND\n\n" + "Control the udev daemon.\n\n" + " -h --help Show this help\n" + " --version Show package version\n" + " -e --exit Instruct the daemon to cleanup and exit\n" + " -l --log-priority=LEVEL Set the udev log level for the daemon\n" + " -s --stop-exec-queue Do not execute events, queue only\n" + " -S --start-exec-queue Execute events, flush queue\n" + " -R --reload Reload rules and databases\n" + " -p --property=KEY=VALUE Set a global property for all events\n" + " -m --children-max=N Maximum number of children\n" + " --timeout=SECONDS Maximum time to block for a reply\n" + , program_invocation_short_name); } -static int adm_control(struct udev *udev, int argc, char *argv[]) -{ - struct udev_ctrl *uctrl = NULL; +static int adm_control(struct udev *udev, int argc, char *argv[]) { + _cleanup_udev_ctrl_unref_ struct udev_ctrl *uctrl = NULL; int timeout = 60; int rc = 1, c; @@ -85,7 +82,7 @@ static int adm_control(struct udev *udev, int argc, char *argv[]) i = util_log_priority(optarg); if (i < 0) { fprintf(stderr, "invalid number '%s'\n", optarg); - goto out; + return rc; } if (udev_ctrl_send_set_log_level(uctrl, util_log_priority(optarg), timeout) < 0) rc = 2; @@ -114,7 +111,7 @@ static int adm_control(struct udev *udev, int argc, char *argv[]) case 'p': if (strchr(optarg, '=') == NULL) { fprintf(stderr, "expect = instead of '%s'\n", optarg); - goto out; + return rc; } if (udev_ctrl_send_set_env(uctrl, optarg, timeout) < 0) rc = 2; @@ -128,7 +125,7 @@ static int adm_control(struct udev *udev, int argc, char *argv[]) i = strtoul(optarg, &endp, 0); if (endp[0] != '\0' || i < 1) { fprintf(stderr, "invalid number '%s'\n", optarg); - goto out; + return rc; } if (udev_ctrl_send_set_children_max(uctrl, i, timeout) < 0) rc = 2; @@ -156,13 +153,11 @@ static int adm_control(struct udev *udev, int argc, char *argv[]) fprintf(stderr, "Extraneous argument: %s\n", argv[optind]); else if (optind == 1) fprintf(stderr, "Option missing\n"); -out: - udev_ctrl_unref(uctrl); return rc; } const struct udevadm_cmd udevadm_control = { .name = "control", .cmd = adm_control, - .help = "control the udev daemon", + .help = "Control the udev daemon", };