[systemd-commits] 12 commits - man/journalctl.xml man/journald.conf.xml man/udevadm.xml shell-completion/zsh src/journal src/login src/machine src/shared src/systemctl src/udev

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Wed Dec 18 21:05:52 PST 2013


 man/journalctl.xml               |   87 ++++++++++---------
 man/journald.conf.xml            |   10 +-
 man/udevadm.xml                  |  176 ++++++++++++++++++++++++++++-----------
 shell-completion/zsh/_journalctl |   14 +--
 src/journal/journalctl.c         |   34 +++----
 src/login/loginctl.c             |  143 ++++++++++++++++---------------
 src/machine/machinectl.c         |    4 
 src/shared/udev-util.h           |    7 +
 src/systemctl/systemctl.c        |   20 ++--
 src/udev/scsi_id/scsi_id.c       |  167 ++++++++++++++++++-------------------
 src/udev/scsi_id/scsi_id.h       |    8 -
 src/udev/udevadm-control.c       |   70 ++++++---------
 src/udev/udevadm-hwdb.c          |   37 +++-----
 src/udev/udevadm-info.c          |  124 +++++++++++----------------
 src/udev/udevadm-monitor.c       |   86 ++++++++-----------
 src/udev/udevadm-settle.c        |   65 +++++++-------
 src/udev/udevadm-test-builtin.c  |   17 +--
 src/udev/udevadm-test.c          |   35 +++----
 src/udev/udevadm-trigger.c       |  124 ++++++++++++---------------
 19 files changed, 633 insertions(+), 595 deletions(-)

New commits:
commit a669d6226da35d8689898b57bcb6a449046e7a3c
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Wed Dec 18 22:10:17 2013 -0500

    systemct: add empty line between units in cat

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index aab92c4..d1f6875 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3746,6 +3746,7 @@ static int cat(sd_bus *bus, char **args) {
         _cleanup_free_ char *unit = NULL, *n = NULL;
         int r = 0;
         char **name;
+        bool first = true;
 
         assert(bus);
         assert(args);
@@ -3796,11 +3797,16 @@ static int cat(sd_bus *bus, char **args) {
                         continue;
                 }
 
+                if (first)
+                        first = false;
+                else
+                        puts("");
+
                 if (!isempty(fragment_path)) {
-                        fprintf(stdout, "%s# %s%s\n",
-                                ansi_highlight_blue(),
-                                fragment_path,
-                                ansi_highlight_off());
+                        printf("%s# %s%s\n",
+                               ansi_highlight_blue(),
+                               fragment_path,
+                               ansi_highlight_off());
                         fflush(stdout);
 
                         r = sendfile_full(STDOUT_FILENO, fragment_path);
@@ -3811,9 +3817,9 @@ static int cat(sd_bus *bus, char **args) {
                 }
 
                 STRV_FOREACH(path, dropin_paths) {
-                        fprintf(stdout,   "%s# %s\n",
-                                isempty(fragment_path) && path == dropin_paths ? "" : "\n",
-                                *path);
+                        printf("%s# %s\n",
+                               isempty(fragment_path) && path == dropin_paths ? "" : "\n",
+                               *path);
                         fflush(stdout);
 
                         r = sendfile_full(STDOUT_FILENO, *path);

commit 495cb9bbeb0bf2959f12e69253465a6aa03e7aef
Author: Djalal Harouni <tixxdz at opendz.org>
Date:   Tue Dec 17 19:42:03 2013 +0100

    loginctl: improve print_{session|user|seat}_status_info() functions
    
    1) Instead of checking if we need to print a new line on each iteration,
    pass the "new_line" as a pointer to those functions, so they can use
    it to check if a new line is needed. This makes the code more consistent
    as it is done in other places: machinectl, systemctl...
    
    2) Move the error messages from show_{session|user|seat}() to their
    appropriate print_{session|user|seat}_status_info() functions, this will
    prevent from logging an error message twice in case show_properties()
    fails and it will improve code readability.
    
    3) Also do not ignore error codes on these functions.

diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 01df999..5f3221e 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -346,7 +346,7 @@ static int prop_map_sessions_strv(sd_bus *bus, const char *member, sd_bus_messag
         return sd_bus_message_exit_container(m);
 }
 
-static int print_session_status_info(sd_bus *bus, const char *path) {
+static int print_session_status_info(sd_bus *bus, const char *path, bool *new_line) {
 
         static const struct bus_properties_map map[]  = {
                 { "Id",         "s", NULL, offsetof(SessionStatusInfo, id) },
@@ -375,8 +375,15 @@ static int print_session_status_info(sd_bus *bus, const char *path) {
         int r;
 
         r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
-        if (r < 0)
+        if (r < 0) {
+                log_error("Could not get properties: %s", strerror(-r));
                 return r;
+        }
+
+        if (*new_line)
+                printf("\n");
+
+        *new_line = true;
 
         printf("%s - ", strna(i.id));
 
@@ -457,7 +464,7 @@ static int print_session_status_info(sd_bus *bus, const char *path) {
         return 0;
 }
 
-static int print_user_status_info(sd_bus *bus, const char *path) {
+static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line) {
 
         static const struct bus_properties_map map[]  = {
                 { "Name",       "s",     NULL, offsetof(UserStatusInfo, name) },
@@ -476,8 +483,15 @@ static int print_user_status_info(sd_bus *bus, const char *path) {
         int r;
 
         r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
-        if (r < 0)
+        if (r < 0) {
+                log_error("Could not get properties: %s", strerror(-r));
                 goto finish;
+        }
+
+        if (*new_line)
+                printf("\n");
+
+        *new_line = true;
 
         if (i.name)
                 printf("%s (%u)\n", i.name, (unsigned) i.uid);
@@ -517,10 +531,10 @@ static int print_user_status_info(sd_bus *bus, const char *path) {
 finish:
         strv_free(i.sessions);
 
-        return 0;
+        return r;
 }
 
-static int print_seat_status_info(sd_bus *bus, const char *path) {
+static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line) {
 
         static const struct bus_properties_map map[]  = {
                 { "Id",            "s",     NULL, offsetof(SeatStatusInfo, id) },
@@ -533,8 +547,15 @@ static int print_seat_status_info(sd_bus *bus, const char *path) {
         int r;
 
         r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
-        if (r < 0)
+        if (r < 0) {
+                log_error("Could not get properties: %s", strerror(-r));
                 goto finish;
+        }
+
+        if (*new_line)
+                printf("\n");
+
+        *new_line = true;
 
         printf("%s\n", strna(i.id));
 
@@ -569,7 +590,7 @@ static int print_seat_status_info(sd_bus *bus, const char *path) {
 finish:
         strv_free(i.sessions);
 
-        return 0;
+        return r;
 }
 
 static int show_properties(sd_bus *bus, const char *path, bool *new_line) {
@@ -610,9 +631,6 @@ static int show_session(sd_bus *bus, char **args, unsigned n) {
                 _cleanup_bus_message_unref_ sd_bus_message * reply = NULL;
                 const char *path = NULL;
 
-                if (i != 1)
-                        printf("\n");
-
                 r = sd_bus_call_method(
                                 bus,
                                 "org.freedesktop.login1",
@@ -633,11 +651,10 @@ static int show_session(sd_bus *bus, char **args, unsigned n) {
                 if (properties)
                         r = show_properties(bus, path, &new_line);
                 else
-                        r = print_session_status_info(bus, path);
-                if (r < 0) {
-                        log_error("Failed to query session: %s", strerror(-r));
+                        r = print_session_status_info(bus, path, &new_line);
+
+                if (r < 0)
                         return r;
-                }
         }
 
         return 0;
@@ -667,9 +684,6 @@ static int show_user(sd_bus *bus, char **args, unsigned n) {
                 const char *path = NULL;
                 uid_t uid;
 
-                if (i != 1)
-                        printf("\n");
-
                 r = get_user_creds((const char**) (args+i), &uid, NULL, NULL, NULL);
                 if (r < 0) {
                         log_error("Failed to look up user %s: %s", args[i], strerror(-r));
@@ -696,11 +710,10 @@ static int show_user(sd_bus *bus, char **args, unsigned n) {
                 if (properties)
                         r = show_properties(bus, path, &new_line);
                 else
-                        r = print_user_status_info(bus, path);
-                if (r < 0) {
-                        log_error("Failed to query user: %s", strerror(-r));
+                        r = print_user_status_info(bus, path, &new_line);
+
+                if (r < 0)
                         return r;
-                }
         }
 
         return 0;
@@ -729,9 +742,6 @@ static int show_seat(sd_bus *bus, char **args, unsigned n) {
                 _cleanup_bus_message_unref_ sd_bus_message * reply = NULL;
                 const char *path = NULL;
 
-                if (i != 1)
-                        printf("\n");
-
                 r = sd_bus_call_method(
                                 bus,
                                 "org.freedesktop.login1",
@@ -752,11 +762,10 @@ static int show_seat(sd_bus *bus, char **args, unsigned n) {
                 if (properties)
                         r = show_properties(bus, path, &new_line);
                 else
-                        r = print_seat_status_info(bus, path);
-                if (r < 0) {
-                        log_error("Failed to query seat: %s", strerror(-r));
+                        r = print_seat_status_info(bus, path, &new_line);
+
+                if (r < 0)
                         return r;
-                }
         }
 
         return 0;

commit 97aa7b478177f200d250dc0186f49e52b5f6e3c8
Author: Djalal Harouni <tixxdz at opendz.org>
Date:   Tue Dec 17 19:42:01 2013 +0100

    loginctl: use show_properties() to get login1 properties
    
    Commit f8f14b3654bcd introduced a regression that makes loginctl ignore
    the "--property" option.
    
    This patch fixes the bug, it uses a new show_properties() function to
    query and filter properties.

diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index e03b0b9..01df999 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -572,26 +572,37 @@ finish:
         return 0;
 }
 
+static int show_properties(sd_bus *bus, const char *path, bool *new_line) {
+        int r;
+
+        if (*new_line)
+                printf("\n");
+
+        *new_line = true;
+
+        r = bus_print_all_properties(bus, "org.freedesktop.login1", path, arg_property, arg_all);
+        if (r < 0)
+                log_error("Could not get properties: %s", strerror(-r));
+
+        return r;
+}
+
 static int show_session(sd_bus *bus, char **args, unsigned n) {
-        bool show_properties;
+        bool properties, new_line = false;
         unsigned i;
         int r;
 
         assert(bus);
         assert(args);
 
-        show_properties = !strstr(args[0], "status");
+        properties = !strstr(args[0], "status");
 
         pager_open_if_enabled();
 
-        if (show_properties && n <= 1) {
+        if (properties && n <= 1) {
                 /* If not argument is specified inspect the manager
                  * itself */
-                r = bus_print_all_properties(bus, "org.freedesktop.login1", "/org/freedesktop/login1", NULL, arg_all);
-                if (r < 0)
-                        log_error("Failed to query login manager.");
-
-                return r;
+                return show_properties(bus, "/org/freedesktop/login1", &new_line);
         }
 
         for (i = 1; i < n; i++) {
@@ -619,8 +630,8 @@ static int show_session(sd_bus *bus, char **args, unsigned n) {
                 if (r < 0)
                         return bus_log_parse_error(r);
 
-                if (show_properties)
-                        r = bus_print_all_properties(bus, "org.freedesktop.login1", path, NULL, arg_all);
+                if (properties)
+                        r = show_properties(bus, path, &new_line);
                 else
                         r = print_session_status_info(bus, path);
                 if (r < 0) {
@@ -633,25 +644,21 @@ static int show_session(sd_bus *bus, char **args, unsigned n) {
 }
 
 static int show_user(sd_bus *bus, char **args, unsigned n) {
-        bool show_properties;
+        bool properties, new_line = false;
         unsigned i;
         int r;
 
         assert(bus);
         assert(args);
 
-        show_properties = !strstr(args[0], "status");
+        properties = !strstr(args[0], "status");
 
         pager_open_if_enabled();
 
-        if (show_properties && n <= 1) {
+        if (properties && n <= 1) {
                 /* If not argument is specified inspect the manager
                  * itself */
-                r = bus_print_all_properties(bus, "org.freedesktop.login1", "/org/freedesktop/login1", NULL, arg_all);
-                if (r < 0)
-                        log_error("Failed to query login manager.");
-
-                return r;
+                return show_properties(bus, "/org/freedesktop/login1", &new_line);
         }
 
         for (i = 1; i < n; i++) {
@@ -686,8 +693,8 @@ static int show_user(sd_bus *bus, char **args, unsigned n) {
                 if (r < 0)
                         return bus_log_parse_error(r);
 
-                if (show_properties)
-                        r = bus_print_all_properties(bus, "org.freedesktop.login1", path, NULL, arg_all);
+                if (properties)
+                        r = show_properties(bus, path, &new_line);
                 else
                         r = print_user_status_info(bus, path);
                 if (r < 0) {
@@ -700,25 +707,21 @@ static int show_user(sd_bus *bus, char **args, unsigned n) {
 }
 
 static int show_seat(sd_bus *bus, char **args, unsigned n) {
-        bool show_properties;
+        bool properties, new_line = false;
         unsigned i;
         int r;
 
         assert(bus);
         assert(args);
 
-        show_properties = !strstr(args[0], "status");
+        properties = !strstr(args[0], "status");
 
         pager_open_if_enabled();
 
-        if (show_properties && n <= 1) {
+        if (properties && n <= 1) {
                 /* If not argument is specified inspect the manager
                  * itself */
-                r = bus_print_all_properties(bus, "org.freedesktop.login1", "/org/freedesktop/login1", NULL, arg_all);
-                if (r < 0)
-                        log_error("Failed to query login manager.");
-
-                return r;
+                return show_properties(bus, "/org/freedesktop/login1", &new_line);
         }
 
         for (i = 1; i < n; i++) {
@@ -746,8 +749,8 @@ static int show_seat(sd_bus *bus, char **args, unsigned n) {
                 if (r < 0)
                         return bus_log_parse_error(r);
 
-                if (show_properties)
-                        r = bus_print_all_properties(bus, "org.freedesktop.login1", path, NULL, arg_all);
+                if (properties)
+                        r = show_properties(bus, path, &new_line);
                 else
                         r = print_seat_status_info(bus, path);
                 if (r < 0) {

commit 1c3051eba4f2a3cbb8417f8d2e11699a67987700
Author: Djalal Harouni <tixxdz at opendz.org>
Date:   Tue Dec 17 19:42:00 2013 +0100

    loginctl: replace strv_append() by strv_extend()

diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index f96a568..e03b0b9 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -1089,7 +1089,7 @@ static int parse_argv(int argc, char *argv[]) {
                 {}
         };
 
-        int c;
+        int c, r;
 
         assert(argc >= 0);
         assert(argv);
@@ -1107,14 +1107,9 @@ static int parse_argv(int argc, char *argv[]) {
                         return 0;
 
                 case 'p': {
-                        char **l;
-
-                        l = strv_append(arg_property, optarg);
-                        if (!l)
-                                return -ENOMEM;
-
-                        strv_free(arg_property);
-                        arg_property = l;
+                        r = strv_extend(&arg_property, optarg);
+                        if (r < 0)
+                                return log_oom();
 
                         /* If the user asked for a particular
                          * property, show it to him, even if it is

commit c736283bfb81f5b00756e08a13946c113a41527f
Author: Jason St. John <jstjohn at purdue.edu>
Date:   Tue Dec 17 21:36:27 2013 -0500

    journalctl,zsh-completion: fix several issues in --help message text
    
    -- fix grammar and reword some descriptions for clarity
    -- add a useful description of what --follow does
    -- fix the description for --after-cursor
    -- properly introduce the FSS acronym for "Forward Secure Sealing" in
    both sections
    -- clarify the --disk-usage command
    
    [zj: perform similar changes to zsh completions]
    
    squash! journalctl: fix several issues in --help message text

diff --git a/shell-completion/zsh/_journalctl b/shell-completion/zsh/_journalctl
index d94c1e4..0d16a26 100644
--- a/shell-completion/zsh/_journalctl
+++ b/shell-completion/zsh/_journalctl
@@ -65,14 +65,14 @@ _arguments -s \
     {-m,--merge}'[Show entries from all available journals]' \
     {-b+,--boot=}'[Show data only from the specified boot or offset]:boot id or offset:_journal_boots' \
     '--list-boots[List boots ordered by time]' \
-    {-k,--dmesg}'[Show only kernel messages, Implies -b]' \
+    {-k,--dmesg}'[Show only kernel messages from the current boot]' \
     {-u+,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
     '--user-unit=[Show data only from the specified user session unit]:units:_journal_fields USER_UNIT' \
     {-p+,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
-    {-c+,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \
-    '--after-cursor=[Start showing entries from the location in the journal after the cursor]:cursors:_journal_fields __CURSORS' \
-    '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
-    '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
+    {-c+,--cursor=}'[Start showing entries from the specified cursor]:cursors:_journal_fields __CURSORS' \
+    '--after-cursor=[Start showing entries from after the specified cursor]:cursors:_journal_fields __CURSORS' \
+    '--since=[Start showing entries on or newer than the specified date]:YYYY-MM-DD HH\:MM\:SS' \
+    '--until=[Stop showing entries on or older than the specified date]:YYYY-MM-DD HH\:MM\:SS' \
     {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
     '--system[Show system and kernel messages]' \
     '--user[Show messages from user services]' \
@@ -85,8 +85,8 @@ _arguments -s \
     '--list-catalog[List messages in catalog]' \
     '--dump-catalog[Dump messages in catalog]' \
     '--update-catalog[Update binary catalog database]' \
-    '--setup-keys[Generate new FSS key pair]' \
-    '--force[Force recreation of FSS keys]' \
+    '--setup-keys[Generate a new FSS key pair]' \
+    '--force[Force recreation of the FSS keys]' \
     '--interval=[Time interval for changing the FSS sealing key]:time interval' \
     '--verify[Verify journal file consistency]' \
     '--verify-key=[Specify FSS verification key]:FSS key' \
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index cc338e0..cb252eb 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -130,31 +130,31 @@ static int help(void) {
                "Query the journal.\n\n"
                "Flags:\n"
                "     --system              Show only the system journal\n"
-               "     --user                Show only the user journal for current user\n"
+               "     --user                Show only the user journal for the current user\n"
                "  -M --machine=CONTAINER   Operate on local container\n"
-               "     --since=DATE          Start showing entries newer or of the specified date\n"
-               "     --until=DATE          Stop showing entries older or of the specified date\n"
-               "  -c --cursor=CURSOR       Start showing entries from specified cursor\n"
-               "     --after-cursor=CURSOR Start showing entries from specified cursor\n"
+               "     --since=DATE          Start showing entries on or newer than the specified date\n"
+               "     --until=DATE          Stop showing entries on or older than the specified date\n"
+               "  -c --cursor=CURSOR       Start showing entries from the specified cursor\n"
+               "     --after-cursor=CURSOR Start showing entries from after the specified cursor\n"
                "     --show-cursor         Print the cursor after all the entries\n"
-               "  -b --boot[=ID]           Show data only from ID or current boot if unspecified\n"
+               "  -b --boot[=ID]           Show data only from ID or, if unspecified, the current boot\n"
                "     --list-boots          Show terse information about recorded boots\n"
-               "  -k --dmesg               Show kernel message log from current boot\n"
+               "  -k --dmesg               Show kernel message log from the current boot\n"
                "  -u --unit=UNIT           Show data only from the specified unit\n"
                "     --user-unit=UNIT      Show data only from the specified user session unit\n"
                "  -p --priority=RANGE      Show only messages within the specified priority range\n"
                "  -e --pager-end           Immediately jump to end of the journal in the pager\n"
-               "  -f --follow              Follow journal\n"
+               "  -f --follow              Follow the journal\n"
                "  -n --lines[=INTEGER]     Number of journal entries to show\n"
                "     --no-tail             Show all lines, even in follow mode\n"
                "  -r --reverse             Show the newest entries first\n"
                "  -o --output=STRING       Change journal output mode (short, short-iso,\n"
-               "                           short-precise, short-monotonic, verbose,\n"
-               "                           export, json, json-pretty, json-sse, cat)\n"
+               "                                   short-precise, short-monotonic, verbose,\n"
+               "                                   export, json, json-pretty, json-sse, cat)\n"
                "  -x --catalog             Add message explanations where available\n"
                "     --no-full             Ellipsize fields\n"
                "  -a --all                 Show all fields, including long and unprintable\n"
-               "  -q --quiet               Don't show privilege warning\n"
+               "  -q --quiet               Do not show privilege warning\n"
                "     --no-pager            Do not pipe output into a pager\n"
                "  -m --merge               Show entries from all available journals\n"
                "  -D --directory=PATH      Show journal files from directory\n"
@@ -163,20 +163,20 @@ static int help(void) {
 #ifdef HAVE_GCRYPT
                "     --interval=TIME       Time interval for changing the FSS sealing key\n"
                "     --verify-key=KEY      Specify FSS verification key\n"
-               "     --force               Force overriding new FSS key pair with --setup-keys\n"
+               "     --force               Force overriding of the FSS key pair with --setup-keys\n"
 #endif
                "\nCommands:\n"
-               "  -h --help                Show this help\n"
+               "  -h --help                Show this help text\n"
                "     --version             Show package version\n"
-               "     --new-id128           Generate a new 128 Bit ID\n"
+               "     --new-id128           Generate a new 128-bit ID\n"
                "     --header              Show journal header information\n"
-               "     --disk-usage          Show total disk usage\n"
-               "  -F --field=FIELD         List all values a certain field takes\n"
+               "     --disk-usage          Show total disk usage of all journal files\n"
+               "  -F --field=FIELD         List all values that a specified field takes\n"
                "     --list-catalog        Show message IDs of all entries in the message catalog\n"
                "     --dump-catalog        Show entries in the message catalog\n"
                "     --update-catalog      Update the message catalog database\n"
 #ifdef HAVE_GCRYPT
-               "     --setup-keys          Generate new FSS key pair\n"
+               "     --setup-keys          Generate a new FSS key pair\n"
                "     --verify              Verify journal file consistency\n"
 #endif
                , program_invocation_short_name);

commit 06d9d3efa554ffc63b5977f1d86e393edeef8ad1
Author: Jason St. John <jstjohn at purdue.edu>
Date:   Tue Dec 17 19:40:02 2013 -0500

    man: add DOI for refereed article on Forward Secure Sealing to journald.conf(5)
    
    In journalctl(1), be more explicit about the reference to "Seal=" in
    journald.conf(5) and what information can be found there.

diff --git a/man/journalctl.xml b/man/journalctl.xml
index 23bb960..2de7252 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -800,10 +800,14 @@
                                 sealing key is stored in the journal
                                 data directory and shall remain on the
                                 host. The verification key should be
-                                stored externally. Also see the
+                                stored externally. Refer to the
                                 <option>Seal=</option> option in
                                 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-                                for details.</para></listitem>
+                                for information on Forward Secure
+                                Sealing and for a link to a refereed
+                                scholarly paper detailing the
+                                cryptographic theory it is based on.
+                                </para></listitem>
                         </varlistentry>
 
                         <varlistentry>
diff --git a/man/journald.conf.xml b/man/journald.conf.xml
index 7aa2e78..8e642a3 100644
--- a/man/journald.conf.xml
+++ b/man/journald.conf.xml
@@ -130,15 +130,15 @@
                                 by
                                 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
                                 <option>--setup-keys</option>
-                                command), forward secure sealing (FSS)
+                                command), Forward Secure Sealing (FSS)
                                 for all persistent journal files is
                                 enabled. FSS is based on <ulink
                                 url="https://eprint.iacr.org/2013/397">Seekable
                                 Sequential Key Generators</ulink> by
-                                G. A. Marson and B. Poettering and
-                                may be used to protect journal files
-                                from unnoticed
-                                alteration.</para></listitem>
+                                G. A. Marson and B. Poettering
+                                (doi:10.1007/978-3-642-40203-6_7)
+                                and may be used to protect journal files
+                                from unnoticed alteration.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>

commit 9a7adc9a0ed53d6e422321e9196eb83d18afcba5
Author: Jason St. John <jstjohn at purdue.edu>
Date:   Tue Dec 17 18:48:43 2013 -0500

    man: be more explicit about option arguments that take 128-bit IDs in journalctl(1)
    
    It may not be immediately obvious to the reader what "ID128" is, so replace the
    example option argument "ID128" with "128-bit-ID".

diff --git a/man/journalctl.xml b/man/journalctl.xml
index c196ce3..23bb960 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -744,7 +744,7 @@
 
                         <varlistentry>
                                 <term><option>--list-catalog
-                                <optional><replaceable>ID128...</replaceable></optional>
+                                <optional><replaceable>128-bit-ID...</replaceable></optional>
                                 </option></term>
 
                                 <listitem><para>List the contents of
@@ -753,7 +753,7 @@
                                 description strings.</para>
 
                                 <para>If any
-                                <replaceable>ID128</replaceable>s are
+                                <replaceable>128-bit-ID</replaceable>s are
                                 specified, only those entries are shown.
                                 </para>
                                 </listitem>
@@ -761,7 +761,7 @@
 
                         <varlistentry>
                                 <term><option>--dump-catalog
-                                <optional><replaceable>ID128...</replaceable></optional>
+                                <optional><replaceable>128-bit-ID...</replaceable></optional>
                                 </option></term>
 
                                 <listitem><para>Show the contents of
@@ -772,7 +772,7 @@
                                 files).</para>
 
                                 <para>If any
-                                <replaceable>ID128</replaceable>s are
+                                <replaceable>128-bit-ID</replaceable>s are
                                 specified, only those entries are shown.
                                 </para>
                                 </listitem>

commit c98fa7999b82647a5f63b513cbde55cb723ceed5
Author: Jason St. John <jstjohn at purdue.edu>
Date:   Tue Dec 17 18:48:42 2013 -0500

    man: fix grammar issues in journalctl(1)
    
    And add a missing <option> tag around "--setup-keys" under "--force".

diff --git a/man/journalctl.xml b/man/journalctl.xml
index 8577f61..c196ce3 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -84,7 +84,7 @@
                 alternatives, i.e. the resulting output will show
                 entries matching any of the specified matches for the
                 same field. Finally, if the character
-                <literal>+</literal> appears as separate word on the
+                <literal>+</literal> appears as a separate word on the
                 command line, all matches before and after are combined
                 in a disjunction (i.e. logical OR).</para>
 
@@ -112,14 +112,14 @@
                 <command>less</command> by default, and long lines are
                 "truncated" to screen width. The hidden part can be
                 viewed by using the left-arrow and right-arrow
-                keys. Paging can be disabled, see
-                <option>--no-pager</option> and section Environment
-                below.</para>
+                keys. Paging can be disabled; see the
+                <option>--no-pager</option> option and the "Environment"
+                section below.</para>
 
                 <para>When outputing to a tty, lines are colored
                 according to priority: lines of level ERROR and higher
-                are colored red, lines of level NOTICE and higher are
-                highlighted, and other lines are displayed normally.
+                are colored red; lines of level NOTICE and higher are
+                highlighted; and other lines are displayed normally.
                 </para>
         </refsect1>
 
@@ -160,7 +160,7 @@
                                 they do not fit in available columns.
                                 The default is to show full fields,
                                 allowing them to wrap or be truncated
-                                by the pager if one is used.</para>
+                                by the pager, if one is used.</para>
 
                                 <para>The old options
                                 <option>-l</option>/<option>--full</option>
@@ -232,7 +232,7 @@
                                 <term><option>-r</option></term>
                                 <term><option>--reverse</option></term>
 
-                                <listitem><para>Reverse output, so the newest
+                                <listitem><para>Reverse output so the newest
                                 entries are displayed first.</para></listitem>
                         </varlistentry>
 
@@ -352,7 +352,7 @@
                                                         but formats them in
                                                         multiple lines in order
                                                         to make them more
-                                                        readable for humans.</para>
+                                                        readable by humans.</para>
                                                 </listitem>
                                         </varlistentry>
 
@@ -376,7 +376,7 @@
                                                 </term>
                                                 <listitem>
                                                         <para>generates a very
-                                                        terse output only
+                                                        terse output, only
                                                         showing the actual
                                                         message of each journal
                                                         entry with no meta data,
@@ -424,8 +424,8 @@
                                 <term><option>--quiet</option></term>
 
                                 <listitem><para>Suppresses any warning
-                                message regarding inaccessible system
-                                journals when run as normal
+                                messages regarding inaccessible system
+                                journals when run as a normal
                                 user.</para></listitem>
                         </varlistentry>
 
@@ -457,11 +457,11 @@
                                 <replaceable>offset</replaceable> will look up
                                 boots starting from the end of the
                                 journal. Thus, <constant>1</constant> means the
-                                first boot found in the journal in the
+                                first boot found in the journal in
                                 chronological order, <constant>2</constant> the
                                 second and so on; while <constant>-0</constant>
                                 is the last boot, <constant>-1</constant> the
-                                boot before that, and so on. An empty
+                                boot before last, and so on. An empty
                                 <replaceable>offset</replaceable> is equivalent
                                 to specifying <constant>-0</constant>, except
                                 when the current boot is not the last boot
@@ -469,7 +469,7 @@
                                 specified to look at logs from a different
                                 machine).</para>
 
-                                <para>If the 32 character
+                                <para>If the 32-character
                                 <replaceable>ID</replaceable> is specified, it
                                 may optionally be followed by
                                 <replaceable>offset</replaceable> which
@@ -478,7 +478,7 @@
                                 values mean earlier boots and a positive values
                                 mean later boots. If
                                 <replaceable>offset</replaceable> is not
-                                specified, a value of zero is assumed and the
+                                specified, a value of zero is assumed, and the
                                 logs for the boot given by
                                 <replaceable>ID</replaceable> are shown.
                                 </para>
@@ -490,7 +490,7 @@
                                 <term><option>--list-boots</option></term>
 
                                 <listitem><para>Show a tabular list of
-                                boot numbers (relative to current
+                                boot numbers (relative to the current
                                 boot), their IDs, and the timestamps
                                 of the first and last message
                                 pertaining to the boot.
@@ -600,8 +600,8 @@
                                 <listitem><para>The cursor is shown after the last
                                 entry after two dashes:</para>
                                 <programlisting>-- cursor: s=0639...</programlisting>
-                                <para>The format of this the cursor is private
-                                and subject ot change.</para></listitem>
+                                <para>The format of the cursor is private
+                                and subject to change.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
@@ -651,7 +651,7 @@
 
                                 <listitem><para>Show messages from
                                 system services and the kernel (with
-                                <option>--system</option>).  Show
+                                <option>--system</option>). Show
                                 messages from service of current user
                                 (with <option>--user</option>).
                                 If neither is specified, show all
@@ -685,13 +685,13 @@
                         <varlistentry>
                                 <term><option>--file=<replaceable>GLOB</replaceable></option></term>
 
-                                <listitem><para>Takes a file glob as
+                                <listitem><para>Takes a file glob as an
                                 argument. If specified, journalctl will
                                 operate on the specified journal files
                                 matching <replaceable>GLOB</replaceable>
                                 instead of the default runtime and
                                 system journal paths. May be specified
-                                multiple times, in which case files will
+                                multiple times, in which case, files will
                                 be suitably interleaved.</para></listitem>
                         </varlistentry>
 
@@ -699,7 +699,7 @@
                                 <term><option>--root=<replaceable>ROOT</replaceable></option></term>
 
                                 <listitem><para>Takes a directory path
-                                as argument. If specified, journalctl
+                                as an argument. If specified, journalctl
                                 will operate on catalog file hierarchy
                                 underneath the specified directory
                                 instead of the root directory
@@ -713,8 +713,8 @@
                                 <term><option>--new-id128</option></term>
 
                                 <listitem><para>Instead of showing
-                                journal contents, generate a new 128
-                                bit ID suitable for identifying
+                                journal contents, generate a new 128-bit
+                                ID suitable for identifying
                                 messages. This is intended for usage
                                 by developers who need a new
                                 identifier for a new message they
@@ -748,8 +748,8 @@
                                 </option></term>
 
                                 <listitem><para>List the contents of
-                                the message catalog, as table of
-                                message IDs plus their short
+                                the message catalog as a table of
+                                message IDs, plus their short
                                 description strings.</para>
 
                                 <para>If any
@@ -767,9 +767,9 @@
                                 <listitem><para>Show the contents of
                                 the message catalog, with entries
                                 separated by a line consisting of two
-                                dashes and the id (the format is the
+                                dashes and the ID (the format is the
                                 same as <filename>.catalog</filename>
-                                files.</para>
+                                files).</para>
 
                                 <para>If any
                                 <replaceable>ID128</replaceable>s are
@@ -784,7 +784,7 @@
                                 <listitem><para>Update the message
                                 catalog index. This command needs to
                                 be executed each time new catalog
-                                files are installed, removed or
+                                files are installed, removed, or
                                 updated to rebuild the binary catalog
                                 index.</para></listitem>
                         </varlistentry>
@@ -809,9 +809,10 @@
                         <varlistentry>
                                 <term><option>--force</option></term>
 
-                                <listitem><para>When --setup-keys is passed and
-                                Forward Secure Sealing has already been set up,
-                                recreate FSS keys.</para></listitem>
+                                <listitem><para>When
+                                <option>--setup-keys</option> is passed and
+                                Forward Secure Sealing (FSS) has already been
+                                configured, recreate FSS keys.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
@@ -856,8 +857,8 @@
         <refsect1>
                 <title>Exit status</title>
 
-                <para>On success, 0 is returned, a non-zero failure
-                code otherwise.</para>
+                <para>On success, 0 is returned; otherwise, a non-zero
+                failure code is returned.</para>
         </refsect1>
 
         <refsect1>

commit 8c841f21f5042b11acc91cc1b039cb162cbbe8f4
Author: Djalal Harouni <tixxdz at opendz.org>
Date:   Tue Dec 17 23:40:15 2013 +0100

    machinectl: show_properties() already logs the error

diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index fd21a0a..a2af87c 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -304,10 +304,8 @@ static int show(sd_bus *bus, char **args, unsigned n) {
                 /* If no argument is specified, inspect the manager
                  * itself */
                 r = show_properties(bus, "/org/freedesktop/machine1", &new_line);
-                if (r < 0) {
-                        log_error("Failed to query properties: %s", strerror(-r));
+                if (r < 0)
                         return r;
-                }
         }
 
         for (i = 1; i < n; i++) {

commit 44433ebdb14d83750e0acdc4b3630b64f1fa18af
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Dec 17 21:49:07 2013 -0500

    udevadm: modernization

diff --git a/src/shared/udev-util.h b/src/shared/udev-util.h
index 27677af..40f8b77 100644
--- a/src/shared/udev-util.h
+++ b/src/shared/udev-util.h
@@ -29,9 +29,16 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_device*, udev_device_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_enumerate*, udev_enumerate_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_event*, udev_event_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_rules*, udev_rules_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl*, udev_ctrl_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_monitor*, udev_monitor_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_queue*, udev_queue_unref);
 
 #define _cleanup_udev_unref_ _cleanup_(udev_unrefp)
 #define _cleanup_udev_device_unref_ _cleanup_(udev_device_unrefp)
 #define _cleanup_udev_enumerate_unref_ _cleanup_(udev_enumerate_unrefp)
 #define _cleanup_udev_event_unref_ _cleanup_(udev_event_unrefp)
 #define _cleanup_udev_rules_unref_ _cleanup_(udev_rules_unrefp)
+#define _cleanup_udev_ctrl_unref_ _cleanup_(udev_ctrl_unrefp)
+#define _cleanup_udev_monitor_unref_ _cleanup_(udev_monitor_unrefp)
+#define _cleanup_udev_queue_unref_ _cleanup_(udev_queue_unrefp)
+#define _cleanup_udev_list_cleanup_ _cleanup_(udev_list_cleanup)
diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c
index 00a909f..3a6c8ef 100644
--- a/src/udev/udevadm-control.c
+++ b/src/udev/udevadm-control.c
@@ -26,6 +26,7 @@
 #include <sys/un.h>
 
 #include "udev.h"
+#include "udev-util.h"
 
 static void print_help(void)
 {
@@ -43,7 +44,7 @@ static void print_help(void)
 
 static int adm_control(struct udev *udev, int argc, char *argv[])
 {
-        struct udev_ctrl *uctrl = NULL;
+        _cleanup_udev_ctrl_unref_ struct udev_ctrl *uctrl = NULL;
         int timeout = 60;
         int rc = 1, c;
 
@@ -85,7 +86,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 +115,7 @@ static int adm_control(struct udev *udev, int argc, char *argv[])
                 case 'p':
                         if (strchr(optarg, '=') == NULL) {
                                 fprintf(stderr, "expect <KEY>=<value> instead of '%s'\n", optarg);
-                                goto out;
+                                return rc;
                         }
                         if (udev_ctrl_send_set_env(uctrl, optarg, timeout) < 0)
                                 rc = 2;
@@ -128,7 +129,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,8 +157,6 @@ 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;
 }
 
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index 2d2cf43..64bb537 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -30,6 +30,7 @@
 #include <sys/types.h>
 
 #include "udev.h"
+#include "udev-util.h"
 
 static bool skip_attribute(const char *name)
 {
@@ -296,13 +297,13 @@ static struct udev_device *find_device(struct udev *udev, const char *id, const
 
 static int uinfo(struct udev *udev, int argc, char *argv[])
 {
-        struct udev_device *device = NULL;
+        _cleanup_udev_device_unref_ struct udev_device *device = NULL;
         bool root = 0;
         bool export = 0;
         const char *export_prefix = NULL;
         char name[UTIL_PATH_SIZE];
         struct udev_list_entry *list_entry;
-        int rc = 0, c;
+        int c;
 
         static const struct option options[] = {
                 { "name",              required_argument, NULL, 'n' },
@@ -360,48 +361,43 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
                 case 'n': {
                         if (device != NULL) {
                                 fprintf(stderr, "device already specified\n");
-                                rc = 2;
-                                goto exit;
+                                return 2;
                         }
 
                         device = find_device(udev, optarg, "/dev/");
                         if (device == NULL) {
                                 fprintf(stderr, "device node not found\n");
-                                rc = 2;
-                                goto exit;
+                                return 2;
                         }
                         break;
                 }
                 case 'p':
                         if (device != NULL) {
                                 fprintf(stderr, "device already specified\n");
-                                rc = 2;
-                                goto exit;
+                                return 2;
                         }
 
                         device = find_device(udev, optarg, "/sys");
                         if (device == NULL) {
                                 fprintf(stderr, "syspath not found\n");
-                                rc = 2;
-                                goto exit;
+                                return 2;
                         }
                         break;
                 case 'q':
                         action = ACTION_QUERY;
-                        if (streq(optarg, "property") || streq(optarg, "env")) {
+                        if (streq(optarg, "property") || streq(optarg, "env"))
                                 query = QUERY_PROPERTY;
-                        } else if (streq(optarg, "name")) {
+                        else if (streq(optarg, "name"))
                                 query = QUERY_NAME;
-                        } else if (streq(optarg, "symlink")) {
+                        else if (streq(optarg, "symlink"))
                                 query = QUERY_SYMLINK;
-                        } else if (streq(optarg, "path")) {
+                        else if (streq(optarg, "path"))
                                 query = QUERY_PATH;
-                        } else if (streq(optarg, "all")) {
+                        else if (streq(optarg, "all"))
                                 query = QUERY_ALL;
-                        } else {
+                        else {
                                 fprintf(stderr, "unknown query type\n");
-                                rc = 3;
-                                goto exit;
+                                return 3;
                         }
                         break;
                 case 'r':
@@ -416,10 +412,10 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
                         break;
                 case 'e':
                         export_devices(udev);
-                        goto exit;
+                        return 0;
                 case 'c':
                         cleanup_db(udev);
-                        goto exit;
+                        return 0;
                 case 'x':
                         export = true;
                         break;
@@ -428,13 +424,12 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
                         break;
                 case 'V':
                         printf("%s\n", VERSION);
-                        goto exit;
+                        return 0;
                 case 'h':
                         printf("%s\n", usage);
-                        goto exit;
+                        return 0;
                 default:
-                        rc = 1;
-                        goto exit;
+                        return 1;
                 }
 
         switch (action) {
@@ -442,14 +437,12 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
                 if (!device) {
                         if (!argv[optind]) {
                                 fprintf(stderr, "%s\n", usage);
-                                rc = 2;
-                                goto exit;
+                                return 2;
                         }
                         device = find_device(udev, argv[optind], NULL);
                         if (!device) {
                                 fprintf(stderr, "Unknown device, --name=, --path=, or absolute path in /dev/ or /sys expected.\n");
-                                rc = 4;
-                                goto exit;
+                                return 4;
                         }
                 }
 
@@ -459,8 +452,7 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
 
                         if (node == NULL) {
                                 fprintf(stderr, "no device node found\n");
-                                rc = 5;
-                                goto exit;
+                                return 5;
                         }
 
                         if (root)
@@ -484,7 +476,7 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
                         break;
                 case QUERY_PATH:
                         printf("%s\n", udev_device_get_devpath(device));
-                        goto exit;
+                        return 0;
                 case QUERY_PROPERTY:
                         list_entry = udev_device_get_properties_list_entry(device);
                         while (list_entry != NULL) {
@@ -515,26 +507,22 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
                         device = find_device(udev, argv[optind], NULL);
                         if (!device) {
                                 fprintf(stderr, "Unknown device, absolute path in /dev/ or /sys expected.\n");
-                                rc = 4;
-                                goto exit;
+                                return 4;
                         }
                 }
                 if (!device) {
                         fprintf(stderr, "Unknown device, --name=, --path=, or absolute path in /dev/ or /sys expected.\n");
-                        rc = 4;
-                        goto exit;
+                        return 4;
                 }
                 print_device_chain(device);
                 break;
         case ACTION_DEVICE_ID_FILE:
                 if (stat_device(name, export, export_prefix) != 0)
-                        rc = 1;
+                        return 1;
                 break;
         }
 
-exit:
-        udev_device_unref(device);
-        return rc;
+        return 0;
 }
 
 const struct udevadm_cmd udevadm_info = {
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index 2c200b7..94e76da 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -33,6 +33,7 @@
 #include <linux/netlink.h>
 
 #include "udev.h"
+#include "udev-util.h"
 
 static bool udev_exit;
 
@@ -78,18 +79,17 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
 {
         struct sigaction act = {};
         sigset_t mask;
-        int option;
         bool prop = false;
         bool print_kernel = false;
         bool print_udev = false;
-        struct udev_list subsystem_match_list;
-        struct udev_list tag_match_list;
-        struct udev_monitor *udev_monitor = NULL;
-        struct udev_monitor *kernel_monitor = NULL;
-        int fd_ep = -1;
+        _cleanup_udev_list_cleanup_ struct udev_list subsystem_match_list;
+        _cleanup_udev_list_cleanup_ struct udev_list tag_match_list;
+        _cleanup_udev_monitor_unref_ struct udev_monitor *udev_monitor = NULL;
+        _cleanup_udev_monitor_unref_ struct udev_monitor *kernel_monitor = NULL;
+        _cleanup_close_ int fd_ep = -1;
         int fd_kernel = -1, fd_udev = -1;
         struct epoll_event ep_kernel, ep_udev;
-        int rc = 0, c;
+        int c;
 
         static const struct option options[] = {
                 { "property",        no_argument,       NULL, 'p' },
@@ -136,10 +136,9 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
                         break;
                 case 'h':
                         help();
-                        goto out;
+                        return 0;
                 default:
-                        rc = 1;
-                        goto out;
+                        return 1;
                 }
 
         if (!print_kernel && !print_udev) {
@@ -160,7 +159,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
         fd_ep = epoll_create1(EPOLL_CLOEXEC);
         if (fd_ep < 0) {
                 log_error("error creating epoll fd: %m\n");
-                goto out;
+                return 1;
         }
 
         printf("monitor will print the received events for:\n");
@@ -170,8 +169,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
                 udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
                 if (udev_monitor == NULL) {
                         fprintf(stderr, "error: unable to create netlink socket\n");
-                        rc = 1;
-                        goto out;
+                        return 1;
                 }
                 udev_monitor_set_receive_buffer_size(udev_monitor, 128*1024*1024);
                 fd_udev = udev_monitor_get_fd(udev_monitor);
@@ -193,8 +191,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
 
                 if (udev_monitor_enable_receiving(udev_monitor) < 0) {
                         fprintf(stderr, "error: unable to subscribe to udev events\n");
-                        rc = 2;
-                        goto out;
+                        return 2;
                 }
 
                 memset(&ep_udev, 0, sizeof(struct epoll_event));
@@ -202,7 +199,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
                 ep_udev.data.fd = fd_udev;
                 if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_udev, &ep_udev) < 0) {
                         log_error("fail to add fd to epoll: %m\n");
-                        goto out;
+                        return 2;
                 }
 
                 printf("UDEV - the event which udev sends out after rule processing\n");
@@ -214,8 +211,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
                 kernel_monitor = udev_monitor_new_from_netlink(udev, "kernel");
                 if (kernel_monitor == NULL) {
                         fprintf(stderr, "error: unable to create netlink socket\n");
-                        rc = 3;
-                        goto out;
+                        return 3;
                 }
                 udev_monitor_set_receive_buffer_size(kernel_monitor, 128*1024*1024);
                 fd_kernel = udev_monitor_get_fd(kernel_monitor);
@@ -229,8 +225,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
 
                 if (udev_monitor_enable_receiving(kernel_monitor) < 0) {
                         fprintf(stderr, "error: unable to subscribe to kernel events\n");
-                        rc = 4;
-                        goto out;
+                        return 4;
                 }
 
                 memset(&ep_kernel, 0, sizeof(struct epoll_event));
@@ -238,7 +233,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
                 ep_kernel.data.fd = fd_kernel;
                 if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_kernel, &ep_kernel) < 0) {
                         log_error("fail to add fd to epoll: %m\n");
-                        goto out;
+                        return 5;
                 }
 
                 printf("KERNEL - the kernel uevent\n");
@@ -277,14 +272,8 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
                         }
                 }
         }
-out:
-        if (fd_ep >= 0)
-                close(fd_ep);
-        udev_monitor_unref(udev_monitor);
-        udev_monitor_unref(kernel_monitor);
-        udev_list_cleanup(&subsystem_match_list);
-        udev_list_cleanup(&tag_match_list);
-        return rc;
+
+        return 0;
 }
 
 const struct udevadm_cmd udevadm_monitor = {
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index 362c3b2..5da0be5 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -35,6 +35,7 @@
 #include <sys/types.h>
 
 #include "udev.h"
+#include "udev-util.h"
 #include "util.h"
 
 static void help(void) {
@@ -65,7 +66,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
         const char *exists = NULL;
         unsigned int timeout = 120;
         struct pollfd pfd[1] = { {.fd = -1}, };
-        struct udev_queue *udev_queue = NULL;
+        _cleanup_udev_queue_unref_ struct udev_queue *udev_queue = NULL;
         int rc = EXIT_FAILURE, c;
 
         while ((c = getopt_long(argc, argv, "s:e:t:E:qh", options, NULL)) >= 0)
@@ -229,7 +230,6 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
 out:
         if (pfd[0].fd >= 0)
                 close(pfd[0].fd);
-        udev_queue_unref(udev_queue);
         return rc;
 }
 
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index cd75fad..a9f9caf 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -30,6 +30,7 @@
 #include <sys/signalfd.h>
 
 #include "udev.h"
+#include "udev-util.h"
 
 static int adm_test(struct udev *udev, int argc, char *argv[])
 {
@@ -37,10 +38,10 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
         char filename[UTIL_PATH_SIZE];
         const char *action = "add";
         const char *syspath = NULL;
-        struct udev_event *event = NULL;
-        struct udev_device *dev = NULL;
-        struct udev_rules *rules = NULL;
         struct udev_list_entry *entry;
+        _cleanup_udev_rules_unref_ struct udev_rules *rules = NULL;
+        _cleanup_udev_device_unref_ struct udev_device *dev = NULL;
+        _cleanup_udev_event_unref_ struct udev_event *event = NULL;
         sigset_t mask, sigmask_orig;
         int err;
         int rc = 0, c;
@@ -154,9 +155,6 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
 out:
         if (event != NULL && event->fd_signal >= 0)
                 close(event->fd_signal);
-        udev_event_unref(event);
-        udev_device_unref(dev);
-        udev_rules_unref(rules);
         udev_builtin_exit(udev);
         return rc;
 }
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index 3608c35..a898ef9 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -32,6 +32,7 @@
 #include <sys/un.h>
 
 #include "udev.h"
+#include "udev-util.h"
 #include "util.h"
 
 static int verbose;
@@ -115,15 +116,12 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
                 TYPE_SUBSYSTEMS,
         } device_type = TYPE_DEVICES;
         const char *action = "change";
-        struct udev_enumerate *udev_enumerate;
-        int rc = 0;
+        _cleanup_udev_enumerate_unref_ struct udev_enumerate *udev_enumerate = NULL;
         int c;
 
         udev_enumerate = udev_enumerate_new(udev);
-        if (udev_enumerate == NULL) {
-                rc = 1;
-                goto exit;
-        }
+        if (udev_enumerate == NULL)
+                return 1;
 
         while ((c = getopt_long(argc, argv, "vno:t:c:s:S:a:A:p:g:y:b:h", options, NULL)) >= 0) {
                 const char *key;
@@ -138,24 +136,22 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
                         dry_run = 1;
                         break;
                 case 't':
-                        if (streq(optarg, "devices")) {
+                        if (streq(optarg, "devices"))
                                 device_type = TYPE_DEVICES;
-                        } else if (streq(optarg, "subsystems")) {
+                        else if (streq(optarg, "subsystems"))
                                 device_type = TYPE_SUBSYSTEMS;
-                        } else {
+                        else {
                                 log_error("unknown type --type=%s\n", optarg);
-                                rc = 2;
-                                goto exit;
+                                return 2;
                         }
                         break;
                 case 'c':
                         if (!nulstr_contains("add\0" "remove\0" "change\0", optarg)) {
                                 log_error("unknown action '%s'\n", optarg);
-                                rc = 2;
-                                goto exit;
-                        } else {
+                                return 2;
+                        } else
                                 action = optarg;
-                        }
+
                         break;
                 case 's':
                         udev_enumerate_add_match_subsystem(udev_enumerate, optarg);
@@ -194,8 +190,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
                         dev = udev_device_new_from_syspath(udev, path);
                         if (dev == NULL) {
                                 log_error("unable to open the device '%s'\n", optarg);
-                                rc = 2;
-                                goto exit;
+                                return 2;
                         }
                         udev_enumerate_add_match_parent(udev_enumerate, dev);
                         /* drop reference immediately, enumerate pins the device as long as needed */
@@ -204,10 +199,9 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
                 }
                 case 'h':
                         help();
-                        goto exit;
+                        return 0;
                 case '?':
-                        rc = 1;
-                        goto exit;
+                        return 1;
                 default:
                         assert_not_reached("Unknown option");
                 }
@@ -222,17 +216,14 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
         case TYPE_SUBSYSTEMS:
                 udev_enumerate_scan_subsystems(udev_enumerate);
                 exec_list(udev_enumerate, action);
-                goto exit;
+                return 0;
         case TYPE_DEVICES:
                 udev_enumerate_scan_devices(udev_enumerate);
                 exec_list(udev_enumerate, action);
-                goto exit;
+                return 0;
         default:
                 assert_not_reached("device_type");
         }
-exit:
-        udev_enumerate_unref(udev_enumerate);
-        return rc;
 }
 
 const struct udevadm_cmd udevadm_trigger = {

commit 7643ac9a8add1f07ffc237c054feb443b5612717
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Dec 17 21:48:14 2013 -0500

    udevadm,scsi_id: add short options to help strings and to the man page
    
    Also clean things up a bit here and there.

diff --git a/man/udevadm.xml b/man/udevadm.xml
index 30a6ac4..6fc4e8d 100644
--- a/man/udevadm.xml
+++ b/man/udevadm.xml
@@ -82,6 +82,7 @@
         </listitem>
       </varlistentry>
       <varlistentry>
+        <term><option>-h</option></term>
         <term><option>--help</option></term>
         <listitem>
           <para>Print help text.</para>
@@ -89,26 +90,28 @@
       </varlistentry>
     </variablelist>
 
-    <refsect2><title>udevadm info <replaceable>options</replaceable></title>
+    <refsect2><title>udevadm info <optional><replaceable>OPTIONS</replaceable></optional> <optional><replaceable>DEVPATH</replaceable>|<replaceable>FILE</replaceable></optional></title>
       <para>Queries the udev database for device information
       stored in the udev database. It can also query the properties
       of a device from its sysfs representation to help creating udev
       rules that match this device.</para>
       <variablelist>
         <varlistentry>
-          <term><option>--query=<replaceable>type</replaceable></option></term>
+          <term><option>-q</option></term>
+          <term><option>--query=<replaceable>TYPE</replaceable></option></term>
           <listitem>
             <para>Query the database for the specified type of device
             data. It needs the <option>--path</option> or
-            <option>--name</option> to identify the specified
-            device. Valid queries are: <constant>name</constant>,
-            <constant>symlink</constant>, <constant>path</constant>,
-            <constant>property</constant>,
+            <option>--name</option> to identify the specified device.
+            Valid <replaceable>TYPE</replaceable>s are:
+            <constant>name</constant>, <constant>symlink</constant>,
+            <constant>path</constant>, <constant>property</constant>,
             <constant>all</constant>.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--path=<replaceable>devpath</replaceable></option></term>
+          <term><option>-p</option></term>
+          <term><option>--path=<replaceable>DEVPATH</replaceable></option></term>
           <listitem>
             <para>The <filename>/sys</filename> path of the device to
             query, e.g.
@@ -121,7 +124,8 @@
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--name=<replaceable>file</replaceable></option></term>
+          <term><option>-n</option></term>
+          <term><option>--name=<replaceable>FILE</replaceable></option></term>
           <listitem>
             <para>The name of the device node or a symlink to query,
             e.g. <filename><optional>/dev</optional>/sda</filename>.
@@ -132,6 +136,7 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-r</option></term>
           <term><option>--root</option></term>
           <listitem>
             <para>Print absolute paths in <command>name</command> or <command>symlink</command>
@@ -139,6 +144,7 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-a</option></term>
           <term><option>--attribute-walk</option></term>
           <listitem>
             <para>Print all sysfs properties of the specified device that can be used
@@ -147,31 +153,36 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-x</option></term>
           <term><option>--export</option></term>
           <listitem>
             <para>Print output as key/value pairs. Values are enclosed in single quotes.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--export-prefix=<replaceable>name</replaceable></option></term>
+          <term><option>-P</option></term>
+          <term><option>--export-prefix=<replaceable>NAME</replaceable></option></term>
           <listitem>
             <para>Add a prefix to the key name of exported values.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--device-id-of-file=<replaceable>file</replaceable></option></term>
+          <term><option>-d</option></term>
+          <term><option>--device-id-of-file=<replaceable>FILE</replaceable></option></term>
           <listitem>
             <para>Print major/minor numbers of the underlying device, where the file
             lives on.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-e</option></term>
           <term><option>--export-db</option></term>
           <listitem>
             <para>Export the content of the udev database.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-c</option></term>
           <term><option>--cleanup-db</option></term>
           <listitem>
             <para>Cleanup the udev database.</para>
@@ -184,6 +195,7 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
@@ -196,19 +208,22 @@
       <para>Request device events from the kernel. Primarily used to replay events at system coldplug time.</para>
       <variablelist>
         <varlistentry>
+          <term><option>-v</option></term>
           <term><option>--verbose</option></term>
           <listitem>
             <para>Print the list of devices which will be triggered.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-n</option></term>
           <term><option>--dry-run</option></term>
           <listitem>
             <para>Do not actually trigger the event.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--type=<replaceable>type</replaceable></option></term>
+          <term><option>-t</option></term>
+          <term><option>--type=<replaceable>TYPE</replaceable></option></term>
           <listitem>
             <para>Trigger a specific type of devices. Valid types are:
             <command>devices</command>, <command>subsystems</command>.
@@ -216,68 +231,95 @@
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--action=<replaceable>action</replaceable></option></term>
+          <term><option>-c</option></term>
+          <term><option>--action=<replaceable>ACTION</replaceable></option></term>
           <listitem>
-            <para>Type of event to be triggered. The default value is <command>change</command>.</para>
+            <para>Type of event to be triggered. The default value is
+            <command>change</command>.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--subsystem-match=<replaceable>subsystem</replaceable></option></term>
+          <term><option>-s</option></term>
+          <term><option>--subsystem-match=<replaceable>SUBSYSTEM</replaceable></option></term>
           <listitem>
-            <para>Trigger events for devices which belong to a matching subsystem. This option
-            can be specified multiple times and supports shell style pattern matching.</para>
+            <para>Trigger events for devices which belong to a
+            matching subsystem. This option can be specified multiple
+            times and supports shell style pattern matching.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--subsystem-nomatch=<replaceable>subsystem</replaceable></option></term>
+          <term><option>-S</option></term>
+          <term><option>--subsystem-nomatch=<replaceable>SUBSYSTEM</replaceable></option></term>
           <listitem>
             <para>Do not trigger events for devices which belong to a matching subsystem. This option
             can be specified multiple times and supports shell style pattern matching.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--attr-match=<replaceable>attribute</replaceable>=<replaceable>value</replaceable></option></term>
+          <term><option>-a</option></term>
+          <term><option>--attr-match=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
           <listitem>
-            <para>Trigger events for devices with a matching sysfs attribute. If a value is specified
-            along with the attribute name, the content of the attribute is matched against the given
-            value using shell style pattern matching. If no value is specified, the existence of the
-            sysfs attribute is checked. This option can be specified multiple times.</para>
+            <para>Trigger events for devices with a matching sysfs
+            attribute. If a value is specified along with the
+            attribute name, the content of the attribute is matched
+            against the given value using shell style pattern
+            matching. If no value is specified, the existence of the
+            sysfs attribute is checked. This option can be specified
+            multiple times.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--attr-nomatch=<replaceable>attribute</replaceable>=<replaceable>value</replaceable></option></term>
+          <term><option>-A</option></term>
+          <term><option>--attr-nomatch=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
           <listitem>
-            <para>Do not trigger events for devices with a matching sysfs attribute. If a value is
-            specified along with the attribute name, the content of the attribute is matched against
-            the given value using shell style pattern matching. If no value is specified, the existence
-            of the sysfs attribute is checked. This option can be specified multiple times.</para>
+            <para>Do not trigger events for devices with a matching
+            sysfs attribute. If a value is specified along with the
+            attribute name, the content of the attribute is matched
+            against the given value using shell style pattern
+            matching. If no value is specified, the existence of the
+            sysfs attribute is checked. This option can be specified
+            multiple times.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--property-match=<replaceable>property</replaceable>=<replaceable>value</replaceable></option></term>
+          <term><option>-p</option></term>
+          <term><option>--property-match=<replaceable>PROPERTY</replaceable>=<replaceable>VALUE</replaceable></option></term>
           <listitem>
-            <para>Trigger events for devices with a matching property value. This option can be
-            specified multiple times and supports shell style pattern matching.</para>
+            <para>Trigger events for devices with a matching property
+            value. This option can be specified multiple times and
+            supports shell style pattern matching.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--tag-match=<replaceable>property</replaceable></option></term>
+          <term><option>-g</option></term>
+          <term><option>--tag-match=<replaceable>PROPERTY</replaceable></option></term>
           <listitem>
-            <para>Trigger events for devices with a matching tag. This option can be
-            specified multiple times.</para>
+            <para>Trigger events for devices with a matching tag. This
+            option can be specified multiple times.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--sysname-match=<replaceable>name</replaceable></option></term>
+          <term><option>-y</option></term>
+          <term><option>--sysname-match=<replaceable>NAME</replaceable></option></term>
           <listitem>
-            <para>Trigger events for devices with a matching sys device name. This option can be
-            specified multiple times and supports shell style pattern matching.</para>
+            <para>Trigger events for devices with a matching sys
+            device name. This option can be specified multiple times
+            and supports shell style pattern matching.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--parent-match=<replaceable>syspath</replaceable></option></term>
+          <term><option>-b</option></term>
+          <term><option>--parent-match=<replaceable>SYSPATH</replaceable></option></term>
           <listitem>
-            <para>Trigger events for all children of a given device.</para>
+            <para>Trigger events for all children of a given
+            device.</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term><option>-h</option></term>
+          <term><option>--help</option></term>
+          <listitem>
+            <para>Print help text.</para>
           </listitem>
         </varlistentry>
       </variablelist>
@@ -287,38 +329,46 @@
       <para>Watches the udev event queue, and exits if all current events are handled.</para>
       <variablelist>
         <varlistentry>
-          <term><option>--timeout=<replaceable>seconds</replaceable></option></term>
+          <term><option>-t</option></term>
+          <term><option>--timeout=<replaceable>SECONDS</replaceable></option></term>
           <listitem>
-            <para>Maximum number of seconds to wait for the event queue to become empty.
-            The default value is 120 seconds. A value of 0 will check if the queue is empty
-            and always return immediately.</para>
+            <para>Maximum number of seconds to wait for the event
+            queue to become empty. The default value is 120 seconds. A
+            value of 0 will check if the queue is empty and always
+            return immediately.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--seq-start=<replaceable>seqnum</replaceable></option></term>
+          <term><option>-s</option></term>
+          <term><option>--seq-start=<replaceable>SEQNUM</replaceable></option></term>
           <listitem>
-            <para>Wait only for events after the given sequence number.</para>
+            <para>Wait only for events after the given sequence
+            number.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--seq-end=<replaceable>seqnum</replaceable></option></term>
+          <term><option>-e</option></term>
+          <term><option>--seq-end=<replaceable>SEQNUM</replaceable></option></term>
           <listitem>
             <para>Wait only for events before the given sequence number.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><option>--exit-if-exists=<replaceable>file</replaceable></option></term>
+          <term><option>-E</option></term>
+          <term><option>--exit-if-exists=<replaceable>FILE</replaceable></option></term>
           <listitem>
             <para>Stop waiting if file exists.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-q</option></term>
           <term><option>--quiet</option></term>
           <listitem>
             <para>Do not print any output, like the remaining queue entries when reaching the timeout.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
@@ -331,12 +381,14 @@
       <para>Modify the internal state of the running udev daemon.</para>
       <variablelist>
         <varlistentry>
+          <term><option>-x</option></term>
           <term><option>--exit</option></term>
           <listitem>
             <para>Signal and wait for systemd-udevd to exit.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-l</option></term>
           <term><option>--log-priority=<replaceable>value</replaceable></option></term>
           <listitem>
             <para>Set the internal log level of systemd-udevd. Valid values are the numerical
@@ -345,6 +397,7 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-s</option></term>
           <term><option>--stop-exec-queue</option></term>
           <listitem>
             <para>Signal systemd-udevd to stop executing new events. Incoming events
@@ -352,12 +405,14 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-S</option></term>
           <term><option>--start-exec-queue</option></term>
           <listitem>
             <para>Signal systemd-udevd to enable the execution of events.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-R</option></term>
           <term><option>--reload</option></term>
           <listitem>
             <para>Signal systemd-udevd to reload the rules files and other databases like the kernel
@@ -366,12 +421,14 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-p</option></term>
           <term><option>--property=<replaceable>KEY</replaceable>=<replaceable>value</replaceable></option></term>
           <listitem>
             <para>Set a global property for all events.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-m</option></term>
           <term><option>--children-max=</option><replaceable>value</replaceable></term>
           <listitem>
             <para>Set the maximum number of events, systemd-udevd will handle at the
@@ -385,6 +442,7 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
@@ -400,36 +458,42 @@
       </para>
       <variablelist>
         <varlistentry>
+          <term><option>-k</option></term>
           <term><option>--kernel</option></term>
           <listitem>
             <para>Print the kernel uevents.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-u</option></term>
           <term><option>--udev</option></term>
           <listitem>
             <para>Print the udev event after the rule processing.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-p</option></term>
           <term><option>--property</option></term>
           <listitem>
             <para>Also print the properties of the event.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-s</option></term>
           <term><option>--subsystem-match=<replaceable>string[/string]</replaceable></option></term>
           <listitem>
             <para>Filter events by subsystem[/devtype]. Only udev events with a matching subsystem value will pass.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-t</option></term>
           <term><option>--tag-match=<replaceable>string</replaceable></option></term>
           <listitem>
             <para>Filter events by property. Only udev events with a given tag attached will pass.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
@@ -442,6 +506,7 @@
       <para>Maintain the hardware database index in <filename>/etc/udev/hwdb.bin</filename>.</para>
       <variablelist>
         <varlistentry>
+          <term><option>-u</option></term>
           <term><option>--update</option></term>
           <listitem>
             <para>Compile the hardware database information located in /usr/lib/udev/hwdb.d/,
@@ -452,6 +517,7 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-t</option></term>
           <term><option>--test=<replaceable>string</replaceable></option></term>
           <listitem>
             <para>Query the database with a modalias string, and print the
@@ -459,11 +525,19 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-r</option></term>
           <term><option>--root=<replaceable>string</replaceable></option></term>
           <listitem>
             <para>Alternative root path in the filesystem for reading and writing files.</para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><option>-h</option></term>
+          <term><option>--help</option></term>
+          <listitem>
+            <para>Print help text.</para>
+          </listitem>
+        </varlistentry>
       </variablelist>
     </refsect2>
 
@@ -471,12 +545,14 @@
       <para>Simulate a udev event run for the given device, and print debug output.</para>
       <variablelist>
         <varlistentry>
+          <term><option>-a</option></term>
           <term><option>--action=<replaceable>string</replaceable></option></term>
           <listitem>
             <para>The action string.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-N</option></term>
           <term><option>--resolve-names=<constant>early</constant>|<constant>late</constant>|<constant>never</constant></option></term>
           <listitem>
             <para>Specify when udevadm should resolve names of users
@@ -489,6 +565,7 @@
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
@@ -497,10 +574,13 @@
       </variablelist>
     </refsect2>
 
-    <refsect2><title>udevadm test-builtin <optional>options</optional> <replaceable>command</replaceable> <replaceable>devpath</replaceable></title>
-      <para>Run a built-in command for the given device, and print debug output.</para>
+    <refsect2><title>udevadm test-builtin <optional>options</optional> <replaceable>COMMAND</replaceable> <replaceable>DEVPATH</replaceable></title>
+      <para>Run a built-in command <replaceable>COMMAND</replaceable>
+      for device <replaceable>DEVPATH</replaceable>, and print debug
+      output.</para>
       <variablelist>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index f005638..6a4cf0c 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -44,7 +44,7 @@ static const struct option options[] = {
         { "replace-whitespace", no_argument,       NULL, 'u' },
         { "sg-version",         required_argument, NULL, 's' },
         { "verbose",            no_argument,       NULL, 'v' },
-        { "version",            no_argument,       NULL, 'V' },
+        { "version",            no_argument,       NULL, 'V' }, /* don't advertise -V */
         { "export",             no_argument,       NULL, 'x' },
         { "help",               no_argument,       NULL, 'h' },
         {}
@@ -313,6 +313,22 @@ static int get_file_options(struct udev *udev,
         return retval;
 }
 
+static void help(void) {
+        printf("Usage: scsi_id [OPTION...] DEVICE\n"
+               "  -d,--device=                     device node for SG_IO commands\n"
+               "  -f,--config=                     location of config file\n"
+               "  -p,--page=0x80|0x83|pre-spc3-83  SCSI page (0x80, 0x83, pre-spc3-83)\n"
+               "  -s,--sg-version=3|4              use SGv3 or SGv4\n"
+               "  -b,--blacklisted                 threat device as blacklisted\n"
+               "  -g,--whitelisted                 threat device as whitelisted\n"
+               "  -u,--replace-whitespace          replace all whitespace by underscores\n"
+               "  -v,--verbose                     verbose logging\n"
+               "     --version                     print version\n"
+               "  -x,--export                      print values as environment keys\n"
+               "  -h,--help                        print this help text\n\n");
+
+}
+
 static int set_options(struct udev *udev,
                        int argc, char **argv,
                        char *maj_min_dev)
@@ -325,7 +341,7 @@ static int set_options(struct udev *udev,
          * file) we have to reset this back to 1.
          */
         optind = 1;
-        while ((option = getopt_long(argc, argv, "d:f:ghp:uvVx", options, NULL)) >= 0)
+        while ((option = getopt_long(argc, argv, "d:f:gp:uvVxh", options, NULL)) >= 0)
                 switch (option) {
                 case 'b':
                         all_good = false;
@@ -345,18 +361,7 @@ static int set_options(struct udev *udev,
                         break;
 
                 case 'h':
-                        printf("Usage: scsi_id [OPTION...] DEVICE\n"
-                               "  --device=                     device node for SG_IO commands\n"
-                               "  --config=                     location of config file\n"
-                               "  --page=0x80|0x83|pre-spc3-83  SCSI page (0x80, 0x83, pre-spc3-83)\n"
-                               "  --sg-version=3|4              use SGv3 or SGv4\n"
-                               "  --blacklisted                 threat device as blacklisted\n"
-                               "  --whitelisted                 threat device as whitelisted\n"
-                               "  --replace-whitespace          replace all whitespace by underscores\n"
-                               "  --verbose                     verbose logging\n"
-                               "  --version                     print version\n"
-                               "  --export                      print values as environment keys\n"
-                               "  --help                        print this help text\n\n");
+                        help();
                         exit(0);
 
                 case 'p':
diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c
index c5a1892..00a909f 100644
--- a/src/udev/udevadm-control.c
+++ b/src/udev/udevadm-control.c
@@ -30,35 +30,35 @@
 static void print_help(void)
 {
         printf("Usage: udevadm control COMMAND\n"
-                "  --exit                   instruct the daemon to cleanup and exit\n"
-                "  --log-priority=<level>   set the udev log level for the daemon\n"
-                "  --stop-exec-queue        do not execute events, queue only\n"
-                "  --start-exec-queue       execute events, flush queue\n"
-                "  --reload                 reload rules and databases\n"
-                "  --property=<KEY>=<value> set a global property for all events\n"
-                "  --children-max=<N>       maximum number of children\n"
-                "  --timeout=<seconds>      maximum time to block for a reply\n"
-                "  --help                   print this help text\n\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 int adm_control(struct udev *udev, int argc, char *argv[])
 {
         struct udev_ctrl *uctrl = NULL;
         int timeout = 60;
-        int rc = 1;
+        int rc = 1, c;
 
         static const struct option options[] = {
-                { "exit", no_argument, NULL, 'e' },
-                { "log-priority", required_argument, NULL, 'l' },
-                { "stop-exec-queue", no_argument, NULL, 's' },
-                { "start-exec-queue", no_argument, NULL, 'S' },
-                { "reload", no_argument, NULL, 'R' },
-                { "reload-rules", no_argument, NULL, 'R' },
-                { "property", required_argument, NULL, 'p' },
-                { "env", required_argument, NULL, 'p' },
-                { "children-max", required_argument, NULL, 'm' },
-                { "timeout", required_argument, NULL, 't' },
-                { "help", no_argument, NULL, 'h' },
+                { "exit",             no_argument,       NULL, 'e' },
+                { "log-priority",     required_argument, NULL, 'l' },
+                { "stop-exec-queue",  no_argument,       NULL, 's' },
+                { "start-exec-queue", no_argument,       NULL, 'S' },
+                { "reload",           no_argument,       NULL, 'R' },
+                { "reload-rules",     no_argument,       NULL, 'R' }, /* alias for -R */
+                { "property",         required_argument, NULL, 'p' },
+                { "env",              required_argument, NULL, 'p' }, /* alias for -p */
+                { "children-max",     required_argument, NULL, 'm' },
+                { "timeout",          required_argument, NULL, 't' },
+                { "help",             no_argument,       NULL, 'h' },
                 {}
         };
 
@@ -71,14 +71,8 @@ static int adm_control(struct udev *udev, int argc, char *argv[])
         if (uctrl == NULL)
                 return 2;
 
-        for (;;) {
-                int option;
-
-                option = getopt_long(argc, argv, "el:sSRp:m:h", options, NULL);
-                if (option == -1)
-                        break;
-
-                switch (option) {
+        while ((c = getopt_long(argc, argv, "el:sSRp:m:h", options, NULL)) >= 0)
+                switch (c) {
                 case 'e':
                         if (udev_ctrl_send_exit(uctrl, timeout) < 0)
                                 rc = 2;
@@ -157,12 +151,11 @@ static int adm_control(struct udev *udev, int argc, char *argv[])
                         rc = 0;
                         break;
                 }
-        }
 
-        if (argv[optind] != NULL)
-                fprintf(stderr, "unknown option\n");
+        if (optind < argc)
+                fprintf(stderr, "Extraneous argument: %s\n", argv[optind]);
         else if (optind == 1)
-                fprintf(stderr, "missing option\n");
+                fprintf(stderr, "Option missing\n");
 out:
         udev_ctrl_unref(uctrl);
         return rc;
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index d0cce84..61a3b08 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -526,35 +526,29 @@ static int import_file(struct udev *udev, struct trie *trie, const char *filenam
 
 static void help(void) {
         printf("Usage: udevadm hwdb OPTIONS\n"
-               "  --update            update the hardware database\n"
-               "  --test=<modalias>   query database and print result\n"
-               "  --root=<path>       alternative root path in the filesystem\n"
-               "  --help\n\n");
+               "  -u,--update          update the hardware database\n"
+               "  -t,--test=MODALIAS   query database and print result\n"
+               "  -r,--root=PATH       alternative root path in the filesystem\n"
+               "  -h,--help\n\n");
 }
 
 static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
         static const struct option options[] = {
-                { "update", no_argument, NULL, 'u' },
-                { "root", required_argument, NULL, 'r' },
-                { "test", required_argument, NULL, 't' },
-                { "help", no_argument, NULL, 'h' },
+                { "update", no_argument,       NULL, 'u' },
+                { "test",   required_argument, NULL, 't' },
+                { "root",   required_argument, NULL, 'r' },
+                { "help",   no_argument,       NULL, 'h' },
                 {}
         };
         const char *test = NULL;
         const char *root = "";
         bool update = false;
         struct trie *trie = NULL;
-        int err;
+        int err, c;
         int rc = EXIT_SUCCESS;
 
-        for (;;) {
-                int option;
-
-                option = getopt_long(argc, argv, "ut:r:h", options, NULL);
-                if (option == -1)
-                        break;
-
-                switch (option) {
+        while ((c = getopt_long(argc, argv, "ut:r:h", options, NULL)) >= 0)
+                switch(c) {
                 case 'u':
                         update = true;
                         break;
@@ -567,12 +561,15 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
                 case 'h':
                         help();
                         return EXIT_SUCCESS;
+                case '?':
+                        return EXIT_FAILURE;
+                default:
+                        assert_not_reached("Unknown option");
                 }
-        }
 
         if (!update && !test) {
-                help();
-                return EXIT_SUCCESS;
+                log_error("Either --update or --test must be used");
+                return EXIT_FAILURE;
         }
 
         if (update) {
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index 2ee59fe..2d2cf43 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -302,43 +302,44 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
         const char *export_prefix = NULL;
         char name[UTIL_PATH_SIZE];
         struct udev_list_entry *list_entry;
-        int rc = 0;
+        int rc = 0, c;
 
         static const struct option options[] = {
-                { "name", required_argument, NULL, 'n' },
-                { "path", required_argument, NULL, 'p' },
-                { "query", required_argument, NULL, 'q' },
-                { "attribute-walk", no_argument, NULL, 'a' },
-                { "cleanup-db", no_argument, NULL, 'c' },
-                { "export-db", no_argument, NULL, 'e' },
-                { "root", no_argument, NULL, 'r' },
+                { "name",              required_argument, NULL, 'n' },
+                { "path",              required_argument, NULL, 'p' },
+                { "query",             required_argument, NULL, 'q' },
+                { "attribute-walk",    no_argument,       NULL, 'a' },
+                { "cleanup-db",        no_argument,       NULL, 'c' },
+                { "export-db",         no_argument,       NULL, 'e' },
+                { "root",              no_argument,       NULL, 'r' },
                 { "device-id-of-file", required_argument, NULL, 'd' },
-                { "export", no_argument, NULL, 'x' },
-                { "export-prefix", required_argument, NULL, 'P' },
-                { "version", no_argument, NULL, 'V' },
-                { "help", no_argument, NULL, 'h' },
+                { "export",            no_argument,       NULL, 'x' },
+                { "export-prefix",     required_argument, NULL, 'P' },
+                { "version",           no_argument,       NULL, 'V' },
+                { "help",              no_argument,       NULL, 'h' },
                 {}
         };
 
         static const char *usage =
-                "Usage: udevadm info OPTIONS\n"
-                "  --query=<type>             query device information:\n"
+                "Usage: udevadm info [OPTIONS] [DEVPATH|FILE]\n"
+                " -q,--query=TYPE             query device information:\n"
                 "      name                     name of device node\n"
                 "      symlink                  pointing to node\n"
                 "      path                     sys device path\n"
                 "      property                 the device properties\n"
                 "      all                      all values\n"
-                "  --path=<syspath>           sys device path used for query or attribute walk\n"
-                "  --name=<name>              node or symlink name used for query or attribute walk\n"
-                "  --root                     prepend dev directory to path names\n"
-                "  --attribute-walk           print all key matches while walking along the chain\n"
+                " -p,--path=SYSPATH           sys device path used for query or attribute walk\n"
+                " -n,--name=NAME              node or symlink name used for query or attribute walk\n"
+                " -r,--root                   prepend dev directory to path names\n"
+                " -a,--attribute-walk         print all key matches walking along the chain\n"
                 "                             of parent devices\n"
-                "  --device-id-of-file=<file> print major:minor of device containing this file\n"
-                "  --export                   export key/value pairs\n"
-                "  --export-prefix            export the key name with a prefix\n"
-                "  --export-db                export the content of the udev database\n"
-                "  --cleanup-db               cleanup the udev database\n"
-                "  --help\n";
+                " -d,--device-id-of-file=FILE print major:minor of device containing this file\n"
+                " -x,--export                 export key/value pairs\n"
+                " -P,--export-prefix          export the key name with a prefix\n"
+                " -e,--export-db              export the content of the udev database\n"
+                " -c,--cleanup-db             cleanup the udev database\n"
+                "    --version                print version of the program\n"
+                " -h,--help                   print this message\n";
 
         enum action_type {
                 ACTION_QUERY,
@@ -354,14 +355,8 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
                 QUERY_ALL,
         } query = QUERY_ALL;
 
-        for (;;) {
-                int option;
-
-                option = getopt_long(argc, argv, "aced:n:p:q:rxP:RVh", options, NULL);
-                if (option == -1)
-                        break;
-
-                switch (option) {
+        while ((c = getopt_long(argc, argv, "aced:n:p:q:rxP:RVh", options, NULL)) >= 0)
+                switch (c) {
                 case 'n': {
                         if (device != NULL) {
                                 fprintf(stderr, "device already specified\n");
@@ -441,7 +436,6 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
                         rc = 1;
                         goto exit;
                 }
-        }
 
         switch (action) {
         case ACTION_QUERY:
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index 4d6af49..2c200b7 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -64,6 +64,16 @@ static void print_device(struct udev_device *device, const char *source, int pro
         }
 }
 
+static void help(void) {
+        printf("Usage: udevadm monitor [--property] [--kernel] [--udev] [--help]\n"
+               "  -p,--property                            print the event properties\n"
+               "  -k,--kernel                              print kernel uevents\n"
+               "  -u,--udev                                print udev events\n"
+               "  -s,--subsystem-match=SUBSYSTEM[/DEVTYPE] filter events by subsystem\n"
+               "  -t,--tag-match=TAG                       filter events by tag\n"
+               "  -h,--help\n\n");
+}
+
 static int adm_monitor(struct udev *udev, int argc, char *argv[])
 {
         struct sigaction act = {};
@@ -79,28 +89,24 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
         int fd_ep = -1;
         int fd_kernel = -1, fd_udev = -1;
         struct epoll_event ep_kernel, ep_udev;
-        int rc = 0;
+        int rc = 0, c;
 
         static const struct option options[] = {
-                { "property", no_argument, NULL, 'p' },
-                { "environment", no_argument, NULL, 'e' },
-                { "kernel", no_argument, NULL, 'k' },
-                { "udev", no_argument, NULL, 'u' },
+                { "property",        no_argument,       NULL, 'p' },
+                { "environment",     no_argument,       NULL, 'e' }, /* alias for -p */
+                { "kernel",          no_argument,       NULL, 'k' },
+                { "udev",            no_argument,       NULL, 'u' },
                 { "subsystem-match", required_argument, NULL, 's' },
-                { "tag-match", required_argument, NULL, 't' },
-                { "help", no_argument, NULL, 'h' },
+                { "tag-match",       required_argument, NULL, 't' },
+                { "help",            no_argument,       NULL, 'h' },
                 {}
         };
 
         udev_list_init(udev, &subsystem_match_list, true);
         udev_list_init(udev, &tag_match_list, true);
 
-        for (;;) {
-                option = getopt_long(argc, argv, "pekus:t:h", options, NULL);
-                if (option == -1)
-                        break;
-
-                switch (option) {
+        while((c = getopt_long(argc, argv, "pekus:t:h", options, NULL)) >= 0)
+                switch (c) {
                 case 'p':
                 case 'e':
                         prop = true;
@@ -129,19 +135,12 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
                         udev_list_entry_add(&tag_match_list, optarg, NULL);
                         break;
                 case 'h':
-                        printf("Usage: udevadm monitor [--property] [--kernel] [--udev] [--help]\n"
-                               "  --property                              print the event properties\n"
-                               "  --kernel                                print kernel uevents\n"
-                               "  --udev                                  print udev events\n"
-                               "  --subsystem-match=<subsystem[/devtype]> filter events by subsystem\n"
-                               "  --tag-match=<tag>                       filter events by tag\n"
-                               "  --help\n\n");
+                        help();
                         goto out;
                 default:
                         rc = 1;
                         goto out;
                 }
-        }
 
         if (!print_kernel && !print_udev) {
                 print_kernel = true;
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index 1468f03..362c3b2 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -37,15 +37,25 @@
 #include "udev.h"
 #include "util.h"
 
+static void help(void) {
+        printf("Usage: udevadm settle OPTIONS\n"
+               "  -t,--timeout=<seconds>     maximum time to wait for events\n"
+               "  -s,--seq-start=<seqnum>    first seqnum to wait for\n"
+               "  -e,--seq-end=<seqnum>      last seqnum to wait for\n"
+               "  -E,--exit-if-exists=<file> stop waiting if file exists\n"
+               "  -q,--quiet                 do not print list after timeout\n"
+               "  -h,--help\n\n");
+}
+
 static int adm_settle(struct udev *udev, int argc, char *argv[])
 {
         static const struct option options[] = {
-                { "seq-start", required_argument, NULL, 's' },
-                { "seq-end", required_argument, NULL, 'e' },
-                { "timeout", required_argument, NULL, 't' },
+                { "seq-start",      required_argument, NULL, 's' },
+                { "seq-end",        required_argument, NULL, 'e' },
+                { "timeout",        required_argument, NULL, 't' },
                 { "exit-if-exists", required_argument, NULL, 'E' },
-                { "quiet", no_argument, NULL, 'q' },
-                { "help", no_argument, NULL, 'h' },
+                { "quiet",          no_argument,       NULL, 'q' },
+                { "help",           no_argument,       NULL, 'h' },
                 {}
         };
         usec_t start_usec = now(CLOCK_MONOTONIC);
@@ -56,21 +66,10 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
         unsigned int timeout = 120;
         struct pollfd pfd[1] = { {.fd = -1}, };
         struct udev_queue *udev_queue = NULL;
-        int rc = EXIT_FAILURE;
-
-        for (;;) {
-                int option;
-
-                option = getopt_long(argc, argv, "s:e:t:E:qh", options, NULL);
-                if (option == -1) {
-                        if (optind < argc) {
-                                fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
-                                exit(EXIT_FAILURE);
-                        }
-                        break;
-                }
+        int rc = EXIT_FAILURE, c;
 
-                switch (option) {
+        while ((c = getopt_long(argc, argv, "s:e:t:E:qh", options, NULL)) >= 0)
+                switch (c) {
                 case 's':
                         start = strtoull(optarg, NULL, 0);
                         break;
@@ -87,25 +86,25 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
                                 exit(EXIT_FAILURE);
                         };
                         break;
-                };
-                case 'q':
-                        quiet = 1;
-                        break;
+                }
                 case 'E':
                         exists = optarg;
                         break;
+                case 'q':
+                        quiet = 1;
+                        break;
                 case 'h':
-                        printf("Usage: udevadm settle OPTIONS\n"
-                               "  --timeout=<seconds>     maximum time to wait for events\n"
-                               "  --seq-start=<seqnum>    first seqnum to wait for\n"
-                               "  --seq-end=<seqnum>      last seqnum to wait for\n"
-                               "  --exit-if-exists=<file> stop waiting if file exists\n"
-                               "  --quiet                 do not print list after timeout\n"
-                               "  --help\n\n");
+                        help();
                         exit(EXIT_SUCCESS);
-                default:
+                case '?':
                         exit(EXIT_FAILURE);
+                default:
+                        assert_not_reached("Unkown argument");
                 }
+
+        if (optind < argc) {
+                fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
+                exit(EXIT_FAILURE);
         }
 
         udev_queue = udev_queue_new(udev);
diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c
index f4aa21e..8041878 100644
--- a/src/udev/udevadm-test-builtin.c
+++ b/src/udev/udevadm-test-builtin.c
@@ -37,7 +37,7 @@
 static void help(struct udev *udev)
 {
         fprintf(stderr, "\n");
-        fprintf(stderr, "Usage: udevadm builtin [--help] <command> <syspath>\n");
+        fprintf(stderr, "Usage: udevadm builtin [--help] COMMAND SYSPATH\n");
         udev_builtin_list(udev);
         fprintf(stderr, "\n");
 }
@@ -53,21 +53,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;
+        int rc = EXIT_SUCCESS, c;
 
-        for (;;) {
-                int option;
-
-                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 +72,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;
         }
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index df1409b..cd75fad 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -43,7 +43,7 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
         struct udev_list_entry *entry;
         sigset_t mask, sigmask_orig;
         int err;
-        int rc = 0;
+        int rc = 0, c;
 
         static const struct option options[] = {
                 { "action", required_argument, NULL, 'a' },
@@ -54,14 +54,8 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
 
         log_debug("version %s\n", VERSION);
 
-        for (;;) {
-                int option;
-
-                option = getopt_long(argc, argv, "a:s:N:fh", options, NULL);
-                if (option == -1)
-                        break;
-
-                switch (option) {
+        while((c = getopt_long(argc, argv, "a:N:h", options, NULL)) >= 0)
+                switch (c) {
                 case 'a':
                         action = optarg;
                         break;
@@ -80,15 +74,18 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
                         break;
                 case 'h':
                         printf("Usage: udevadm test OPTIONS <syspath>\n"
-                               "  --action=<string>     set action string\n"
-                               "  --help\n\n");
+                               "  -a,--action=ACTION                  set action string\n"
+                               "  -N,--resolve-names=early|late|never when to resolve names\n"
+                               "  -h,--help                           print this help string\n"
+                               "\n");
                         exit(EXIT_SUCCESS);
-                default:
+                case '?':
                         exit(EXIT_FAILURE);
+                default:
+                        assert_not_reached("Unknown option");
                 }
-        }
-        syspath = argv[optind];
 
+        syspath = argv[optind];
         if (syspath == NULL) {
                 fprintf(stderr, "syspath parameter missing\n");
                 rc = 2;
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index d10ca59..3608c35 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -73,22 +73,41 @@ static const char *keyval(const char *str, const char **val, char *buf, size_t s
         return buf;
 }
 
+static void help(void) {
+        printf("Usage: udevadm trigger OPTIONS\n"
+               "  -v,--verbose                       print the list of devices while running\n"
+               "  -n,--dry-run                       do not actually trigger the events\n"
+               "  -t,--type=                         type of events to trigger\n"
+               "          devices                       sys devices (default)\n"
+               "          subsystems                    sys subsystems and drivers\n"
+               "  -c,--action=<action>               event action value, default is \"change\"\n"
+               "  -s,--subsystem-match=<subsystem>   trigger devices from a matching subsystem\n"
+               "  -S,--subsystem-nomatch=<subsystem> exclude devices from a matching subsystem\n"
+               "  -a,--attr-match=<file[=<value>]>   trigger devices with a matching attribute\n"
+               "  -A,--attr-nomatch=<file[=<value>]> exclude devices with a matching attribute\n"
+               "  -p,--property-match=<key>=<value>  trigger devices with a matching property\n"
+               "  -g,--tag-match=<key>=<value>       trigger devices with a matching property\n"
+               "  -y,--sysname-match=<name>          trigger devices with a matching name\n"
+               "  -b,--parent-match=<name>           trigger devices with that parent device\n"
+               "  -h,--help\n\n");
+}
+
 static int adm_trigger(struct udev *udev, int argc, char *argv[])
 {
         static const struct option options[] = {
-                { "verbose", no_argument, NULL, 'v' },
-                { "dry-run", no_argument, NULL, 'n' },
-                { "type", required_argument, NULL, 't' },
-                { "action", required_argument, NULL, 'c' },
-                { "subsystem-match", required_argument, NULL, 's' },
+                { "verbose",           no_argument,       NULL, 'v' },
+                { "dry-run",           no_argument,       NULL, 'n' },
+                { "type",              required_argument, NULL, 't' },
+                { "action",            required_argument, NULL, 'c' },
+                { "subsystem-match",   required_argument, NULL, 's' },
                 { "subsystem-nomatch", required_argument, NULL, 'S' },
-                { "attr-match", required_argument, NULL, 'a' },
-                { "attr-nomatch", required_argument, NULL, 'A' },
-                { "property-match", required_argument, NULL, 'p' },
-                { "tag-match", required_argument, NULL, 'g' },
-                { "sysname-match", required_argument, NULL, 'y' },
-                { "parent-match", required_argument, NULL, 'b' },
-                { "help", no_argument, NULL, 'h' },
+                { "attr-match",        required_argument, NULL, 'a' },
+                { "attr-nomatch",      required_argument, NULL, 'A' },
+                { "property-match",    required_argument, NULL, 'p' },
+                { "tag-match",         required_argument, NULL, 'g' },
+                { "sysname-match",     required_argument, NULL, 'y' },
+                { "parent-match",      required_argument, NULL, 'b' },
+                { "help",              no_argument,       NULL, 'h' },
                 {}
         };
         enum {
@@ -98,6 +117,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
         const char *action = "change";
         struct udev_enumerate *udev_enumerate;
         int rc = 0;
+        int c;
 
         udev_enumerate = udev_enumerate_new(udev);
         if (udev_enumerate == NULL) {
@@ -105,23 +125,12 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
                 goto exit;
         }
 
-        for (;;) {
-                int option;
+        while ((c = getopt_long(argc, argv, "vno:t:c:s:S:a:A:p:g:y:b:h", options, NULL)) >= 0) {
                 const char *key;
                 const char *val;
                 char buf[UTIL_PATH_SIZE];
 
-                option = getopt_long(argc, argv, "vng:o:t:hc:p:s:S:a:A:y:b:", options, NULL);
-                if (option == -1) {
-                        if (optind < argc) {
-                                fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
-                                rc = 1;
-                                goto exit;
-                        }
-                        break;
-                }
-
-                switch (option) {
+                switch (c) {
                 case 'v':
                         verbose = 1;
                         break;
@@ -194,29 +203,21 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
                         break;
                 }
                 case 'h':
-                        printf("Usage: udevadm trigger OPTIONS\n"
-                               "  --verbose                       print the list of devices while running\n"
-                               "  --dry-run                       do not actually trigger the events\n"
-                               "  --type=                         type of events to trigger\n"
-                               "      devices                       sys devices (default)\n"
-                               "      subsystems                    sys subsystems and drivers\n"
-                               "  --action=<action>               event action value, default is \"change\"\n"
-                               "  --subsystem-match=<subsystem>   trigger devices from a matching subsystem\n"
-                               "  --subsystem-nomatch=<subsystem> exclude devices from a matching subsystem\n"
-                               "  --attr-match=<file[=<value>]>   trigger devices with a matching attribute\n"
-                               "  --attr-nomatch=<file[=<value>]> exclude devices with a matching attribute\n"
-                               "  --property-match=<key>=<value>  trigger devices with a matching property\n"
-                               "  --tag-match=<key>=<value>       trigger devices with a matching property\n"
-                               "  --sysname-match=<name>          trigger devices with a matching name\n"
-                               "  --parent-match=<name>           trigger devices with that parent device\n"
-                               "  --help\n\n");
+                        help();
                         goto exit;
-                default:
+                case '?':
                         rc = 1;
                         goto exit;
+                default:
+                        assert_not_reached("Unknown option");
                 }
         }
 
+        if (optind < argc) {
+                fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
+                return 1;
+        }
+
         switch (device_type) {
         case TYPE_SUBSYSTEMS:
                 udev_enumerate_scan_subsystems(udev_enumerate);

commit ed142bdb68fdcd5ce591152ce0ec9d29898fbac4
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sun Dec 15 17:15:54 2013 -0500

    scsi_id: cleanup
    
    Remove -i option which would case exit(1) to happen.
    Remove some unused code.
    Convert to bool where appropriate.
    Simplify things a bit.
    Always free everything.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1043304

diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index ae36b9e..f005638 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -18,13 +18,14 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
+#include <stdbool.h>
 #include <unistd.h>
 #include <signal.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <syslog.h>
-#include <stdarg.h>
 #include <ctype.h>
 #include <getopt.h>
 #include <sys/stat.h>
@@ -32,34 +33,31 @@
 #include "libudev.h"
 #include "libudev-private.h"
 #include "scsi_id.h"
+#include "udev-util.h"
 
 static const struct option options[] = {
-        { "device", required_argument, NULL, 'd' },
-        { "config", required_argument, NULL, 'f' },
-        { "page", required_argument, NULL, 'p' },
-        { "blacklisted", no_argument, NULL, 'b' },
-        { "whitelisted", no_argument, NULL, 'g' },
-        { "replace-whitespace", no_argument, NULL, 'u' },
-        { "sg-version", required_argument, NULL, 's' },
-        { "verbose", no_argument, NULL, 'v' },
-        { "version", no_argument, NULL, 'V' },
-        { "export", no_argument, NULL, 'x' },
-        { "help", no_argument, NULL, 'h' },
+        { "device",             required_argument, NULL, 'd' },
+        { "config",             required_argument, NULL, 'f' },
+        { "page",               required_argument, NULL, 'p' },
+        { "blacklisted",        no_argument,       NULL, 'b' },
+        { "whitelisted",        no_argument,       NULL, 'g' },
+        { "replace-whitespace", no_argument,       NULL, 'u' },
+        { "sg-version",         required_argument, NULL, 's' },
+        { "verbose",            no_argument,       NULL, 'v' },
+        { "version",            no_argument,       NULL, 'V' },
+        { "export",             no_argument,       NULL, 'x' },
+        { "help",               no_argument,       NULL, 'h' },
         {}
 };
 
-static const char short_options[] = "d:f:ghip:uvVx";
-static const char dev_short_options[] = "bgp:";
-
-static int all_good;
-static int dev_specified;
+static bool all_good = false;
+static bool dev_specified = false;
 static char config_file[MAX_PATH_LEN] = "/etc/scsi_id.config";
-static enum page_code default_page_code;
+static enum page_code default_page_code = PAGE_UNSPECIFIED;
 static int sg_version = 4;
-static int use_stderr;
-static int debug;
-static int reformat_serial;
-static int export;
+static int debug = 0;
+static bool reformat_serial = false;
+static bool export = false;
 static char vendor_str[64];
 static char model_str[64];
 static char vendor_enc_str[256];
@@ -173,7 +171,7 @@ static int get_file_options(struct udev *udev,
                             int *argc, char ***newargv)
 {
         char *buffer;
-        FILE *fd;
+        _cleanup_fclose_ FILE *f;
         char *buf;
         char *str1;
         char *vendor_in, *model_in, *options_in; /* read in from file */
@@ -181,11 +179,11 @@ static int get_file_options(struct udev *udev,
         int c;
         int retval = 0;
 
-        fd = fopen(config_file, "re");
-        if (fd == NULL) {
-                if (errno == ENOENT) {
+        f = fopen(config_file, "re");
+        if (f == NULL) {
+                if (errno == ENOENT)
                         return 1;
-                } else {
+                else {
                         log_error("can't open %s: %m\n", config_file);
                         return -1;
                 }
@@ -197,17 +195,15 @@ static int get_file_options(struct udev *udev,
          * points into this buffer for its strings).
          */
         buffer = malloc(MAX_BUFFER_LEN);
-        if (!buffer) {
-                fclose(fd);
+        if (!buffer)
                 return log_oom();
-        }
 
         *newargv = NULL;
         lineno = 0;
         while (1) {
                 vendor_in = model_in = options_in = NULL;
 
-                buf = fgets(buffer, MAX_BUFFER_LEN, fd);
+                buf = fgets(buffer, MAX_BUFFER_LEN, f);
                 if (buf == NULL)
                         break;
                 lineno++;
@@ -268,10 +264,10 @@ static int get_file_options(struct udev *udev,
                 if (vendor == NULL) {
                         if (vendor_in == NULL)
                                 break;
-                } else if ((vendor_in && strneq(vendor, vendor_in,
-                                                 strlen(vendor_in))) &&
-                           (!model_in || (strneq(model, model_in,
-                                                  strlen(model_in))))) {
+                } else if (vendor_in &&
+                           strneq(vendor, vendor_in, strlen(vendor_in)) &&
+                           (!model_in ||
+                            (strneq(model, model_in, strlen(model_in))))) {
                                 /*
                                  * Matched vendor and optionally model.
                                  *
@@ -314,12 +310,11 @@ static int get_file_options(struct udev *udev,
         }
         if (retval != 0)
                 free(buffer);
-        fclose(fd);
         return retval;
 }
 
 static int set_options(struct udev *udev,
-                       int argc, char **argv, const char *short_opts,
+                       int argc, char **argv,
                        char *maj_min_dev)
 {
         int option;
@@ -330,42 +325,34 @@ static int set_options(struct udev *udev,
          * file) we have to reset this back to 1.
          */
         optind = 1;
-        while (1) {
-                option = getopt_long(argc, argv, short_opts, options, NULL);
-                if (option == -1)
-                        break;
-
+        while ((option = getopt_long(argc, argv, "d:f:ghp:uvVx", options, NULL)) >= 0)
                 switch (option) {
                 case 'b':
-                        all_good = 0;
+                        all_good = false;
                         break;
 
                 case 'd':
-                        dev_specified = 1;
+                        dev_specified = true;
                         strscpy(maj_min_dev, MAX_PATH_LEN, optarg);
                         break;
 
-                case 'e':
-                        use_stderr = 1;
-                        break;
-
                 case 'f':
                         strscpy(config_file, MAX_PATH_LEN, optarg);
                         break;
 
                 case 'g':
-                        all_good = 1;
+                        all_good = true;
                         break;
 
                 case 'h':
-                        printf("Usage: scsi_id OPTIONS <device>\n"
+                        printf("Usage: scsi_id [OPTION...] DEVICE\n"
                                "  --device=                     device node for SG_IO commands\n"
                                "  --config=                     location of config file\n"
                                "  --page=0x80|0x83|pre-spc3-83  SCSI page (0x80, 0x83, pre-spc3-83)\n"
                                "  --sg-version=3|4              use SGv3 or SGv4\n"
                                "  --blacklisted                 threat device as blacklisted\n"
                                "  --whitelisted                 threat device as whitelisted\n"
-                               "  --replace-whitespace          replace all whitespaces by underscores\n"
+                               "  --replace-whitespace          replace all whitespace by underscores\n"
                                "  --verbose                     verbose logging\n"
                                "  --version                     print version\n"
                                "  --export                      print values as environment keys\n"
@@ -373,13 +360,13 @@ static int set_options(struct udev *udev,
                         exit(0);
 
                 case 'p':
-                        if (streq(optarg, "0x80")) {
+                        if (streq(optarg, "0x80"))
                                 default_page_code = PAGE_80;
-                        } else if (streq(optarg, "0x83")) {
+                        else if (streq(optarg, "0x83"))
                                 default_page_code = PAGE_83;
-                        } else if (streq(optarg, "pre-spc3-83")) {
+                        else if (streq(optarg, "pre-spc3-83"))
                                 default_page_code = PAGE_83_PRE_SPC3;
-                        } else {
+                        else {
                                 log_error("Unknown page code '%s'\n", optarg);
                                 return -1;
                         }
@@ -394,11 +381,7 @@ static int set_options(struct udev *udev,
                         break;
 
                 case 'u':
-                        reformat_serial = 1;
-                        break;
-
-                case 'x':
-                        export = 1;
+                        reformat_serial = true;
                         break;
 
                 case 'v':
@@ -410,14 +393,22 @@ static int set_options(struct udev *udev,
                         exit(0);
                         break;
 
+                case 'x':
+                        export = true;
+                        break;
+
+                case '?':
+                        return -1;
+
                 default:
-                        exit(1);
+                        assert_not_reached("Unknown option");
                 }
-        }
+
         if (optind < argc && !dev_specified) {
-                dev_specified = 1;
+                dev_specified = true;
                 strscpy(maj_min_dev, MAX_PATH_LEN, argv[optind]);
         }
+
         return 0;
 }
 
@@ -436,7 +427,7 @@ static int per_dev_options(struct udev *udev,
 
         optind = 1; /* reset this global extern */
         while (retval == 0) {
-                option = getopt_long(newargc, newargv, dev_short_options, options, NULL);
+                option = getopt_long(newargc, newargv, "bgp:", options, NULL);
                 if (option == -1)
                         break;
 
@@ -505,13 +496,11 @@ static int set_inq_values(struct udev *udev, struct scsi_id_device *dev_scsi, co
  */
 static int scsi_id(struct udev *udev, char *maj_min_dev)
 {
-        struct scsi_id_device dev_scsi;
+        struct scsi_id_device dev_scsi = {};
         int good_dev;
         int page_code;
         int retval = 0;
 
-        memset(&dev_scsi, 0x00, sizeof(struct scsi_id_device));
-
         if (set_inq_values(udev, &dev_scsi, maj_min_dev) < 0) {
                 retval = 1;
                 goto out;
@@ -584,11 +573,11 @@ out:
 
 int main(int argc, char **argv)
 {
-        struct udev *udev;
+        _cleanup_udev_unref_ struct udev *udev;
         int retval = 0;
         char maj_min_dev[MAX_PATH_LEN];
         int newargc;
-        char **newargv;
+        char **newargv = NULL;
 
         udev = udev_new();
         if (udev == NULL)
@@ -600,24 +589,24 @@ int main(int argc, char **argv)
         /*
          * Get config file options.
          */
-        newargv = NULL;
         retval = get_file_options(udev, NULL, NULL, &newargc, &newargv);
         if (retval < 0) {
                 retval = 1;
                 goto exit;
         }
-        if (newargv && (retval == 0)) {
-                if (set_options(udev, newargc, newargv, short_options, maj_min_dev) < 0) {
+        if (retval == 0) {
+                assert(newargv);
+
+                if (set_options(udev, newargc, newargv, maj_min_dev) < 0) {
                         retval = 2;
                         goto exit;
                 }
-                free(newargv);
         }
 
         /*
          * Get command line options (overriding any config file settings).
          */
-        if (set_options(udev, argc, argv, short_options, maj_min_dev) < 0)
+        if (set_options(udev, argc, argv, maj_min_dev) < 0)
                 exit(1);
 
         if (!dev_specified) {
@@ -629,7 +618,10 @@ int main(int argc, char **argv)
         retval = scsi_id(udev, maj_min_dev);
 
 exit:
-        udev_unref(udev);
+        if (newargv) {
+                free(newargv[0]);
+                free(newargv);
+        }
         log_close();
         return retval;
 }
diff --git a/src/udev/scsi_id/scsi_id.h b/src/udev/scsi_id/scsi_id.h
index 103e443..648b5ce 100644
--- a/src/udev/scsi_id/scsi_id.h
+++ b/src/udev/scsi_id/scsi_id.h
@@ -66,8 +66,8 @@ int scsi_get_serial(struct udev *udev, struct scsi_id_device *dev_scsi, const ch
  * Page code values.
  */
 enum page_code {
-                PAGE_83_PRE_SPC3 = -0x83,
-                PAGE_UNSPECIFIED = 0x00,
-                PAGE_80          = 0x80,
-                PAGE_83          = 0x83,
+        PAGE_83_PRE_SPC3 = -0x83,
+        PAGE_UNSPECIFIED = 0x00,
+        PAGE_80          = 0x80,
+        PAGE_83          = 0x83,
 };



More information about the systemd-commits mailing list