diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-03-23 03:34:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-23 03:34:46 +0100 |
commit | 14acae357bb7928cadb10335951157559a39ac2e (patch) | |
tree | cee015fbdd1fa38fa110d428aacb3079652e4992 | |
parent | NEWS: adjust MONITOR_ env vars paragraph (diff) | |
parent | homework: s/EWOULDBLOCK/EAGAIN/ (diff) | |
download | systemd-14acae357bb7928cadb10335951157559a39ac2e.tar.xz systemd-14acae357bb7928cadb10335951157559a39ac2e.zip |
Merge pull request #22825 from keszybz/assorted-cleanups
Assorted cleanups
-rw-r--r-- | man/systemd.network.xml | 30 | ||||
-rw-r--r-- | src/basic/errno-to-name.awk | 2 | ||||
-rw-r--r-- | src/home/homework-luks.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-objects.c | 17 | ||||
-rwxr-xr-x | tools/dbus_exporter.py | 47 |
5 files changed, 39 insertions, 61 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml index ec270e5e96..bc2d1615f9 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -2629,10 +2629,10 @@ Token=prefixstable:2002:da8:1::</programlisting></para> <term><varname>BootServerAddress=</varname></term> <listitem> - <para>Takes an IPv4 address of the boot server used by e.g. PXE boot systems. When specified, - the address is set to the <literal>siaddr</literal> field of the DHCP message header. See - <ulink url="https://www.rfc-editor.org/rfc/rfc2131.html">RFC 2131</ulink> for more details. - Defaults to unset.</para> + <para>Takes an IPv4 address of the boot server used by e.g. PXE boot systems. When specified, this + address is sent in the <option>siaddr</option> field of the DHCP message header. See <ulink + url="https://www.rfc-editor.org/rfc/rfc2131.html">RFC 2131</ulink> for more details. Defaults to + unset.</para> </listitem> </varlistentry> @@ -2640,13 +2640,13 @@ Token=prefixstable:2002:da8:1::</programlisting></para> <term><varname>BootServerName=</varname></term> <listitem> - <para>Takes a name of the boot server used by e.g. PXE boot systems. When specified, the - server name is set to the DHCP option 66. See - <ulink url="https://www.rfc-editor.org/rfc/rfc2132.html">RFC 2132</ulink> for more details. - Defaults to unset.</para> - <para>Note that typically one of - <varname>BootServerName=</varname>/<varname>BootServerAddress=</varname> is sufficient to be - set, but both can be set too, if desired.</para> + <para>Takes a name of the boot server used by e.g. PXE boot systems. When specified, this name is + sent in the DHCP option 66 ("TFTP server name"). See <ulink + url="https://www.rfc-editor.org/rfc/rfc2132.html">RFC 2132</ulink> for more details. Defaults to + unset.</para> + + <para>Note that typically setting one of <varname>BootServerName=</varname> or + <varname>BootServerAddress=</varname> is sufficient, but both can be set too, if desired.</para> </listitem> </varlistentry> @@ -2654,10 +2654,10 @@ Token=prefixstable:2002:da8:1::</programlisting></para> <term><varname>BootFilename=</varname></term> <listitem> - <para>Takes a path or URL to a file loaded by e.g. a PXE boot loader. The specified path is - set to the DHCP option 67. See - <ulink url="https://www.rfc-editor.org/rfc/rfc2132.html">RFC 2132</ulink> for more details. - Defaults to unset.</para> + <para>Takes a path or URL to a file loaded by e.g. a PXE boot loader. When specified, this path is + sent in the DHCP option 67 ("Bootfile name"). See <ulink + url="https://www.rfc-editor.org/rfc/rfc2132.html">RFC 2132</ulink> for more details. Defaults to + unset.</para> </listitem> </varlistentry> diff --git a/src/basic/errno-to-name.awk b/src/basic/errno-to-name.awk index 6b18a90e13..8442124488 100644 --- a/src/basic/errno-to-name.awk +++ b/src/basic/errno-to-name.awk @@ -3,7 +3,7 @@ BEGIN{ print "static const char* const errno_names[] = { " } -!/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { +!/(EDEADLOCK|EWOULDBLOCK|ENOTSUP)/ { printf " [%s] = \"%s\",\n", $1, $1 } END{ diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c index 8b3341c643..488cb30fe3 100644 --- a/src/home/homework-luks.c +++ b/src/home/homework-luks.c @@ -1163,12 +1163,12 @@ static int lock_image_fd(int image_fd, const char *ip) { if (flock(image_fd, LOCK_EX|LOCK_NB) < 0) { - if (errno == EWOULDBLOCK) + if (errno == EAGAIN) log_error_errno(errno, "Image file '%s' already locked, can't use.", ip); else log_error_errno(errno, "Failed to lock image file '%s': %m", ip); - return errno != EWOULDBLOCK ? -errno : -EADDRINUSE; /* Make error recognizable */ + return errno != EAGAIN ? -errno : -EADDRINUSE; /* Make error recognizable */ } log_info("Successfully locked image file '%s'.", ip); diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index 519cd198e5..e06a05db4b 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -217,28 +217,26 @@ static int get_child_nodes( const char *prefix, struct node *n, unsigned flags, - OrderedSet **_s, + OrderedSet **ret, sd_bus_error *error) { - OrderedSet *s = NULL; + _cleanup_ordered_set_free_free_ OrderedSet *s = NULL; int r; assert(bus); assert(prefix); assert(n); - assert(_s); + assert(ret); s = ordered_set_new(&string_hash_ops); if (!s) return -ENOMEM; r = add_subtree_to_set(bus, prefix, n, flags, s, error); - if (r < 0) { - ordered_set_free_free(s); + if (r < 0) return r; - } - *_s = s; + *ret = TAKE_PTR(s); return 0; } @@ -1473,7 +1471,7 @@ int bus_process_object(sd_bus *bus, sd_bus_message *m) { return 1; } -static struct node *bus_node_allocate(sd_bus *bus, const char *path) { +static struct node* bus_node_allocate(sd_bus *bus, const char *path) { struct node *n, *parent; const char *e; _cleanup_free_ char *s = NULL; @@ -1499,8 +1497,7 @@ static struct node *bus_node_allocate(sd_bus *bus, const char *path) { if (streq(path, "/")) parent = NULL; else { - e = strrchr(path, '/'); - assert(e); + assert_se(e = strrchr(path, '/')); p = strndupa_safe(path, MAX(1, e - path)); diff --git a/tools/dbus_exporter.py b/tools/dbus_exporter.py index 4da8b82af4..f94f261e07 100755 --- a/tools/dbus_exporter.py +++ b/tools/dbus_exporter.py @@ -4,58 +4,39 @@ from argparse import ArgumentParser from pathlib import Path from subprocess import run, PIPE - def extract_interfaces_xml(output_dir, executable): - list_interfaces_process = run( + proc = run( args=[executable.absolute(), '--bus-introspect', 'list'], stdout=PIPE, check=True, - universal_newlines=True, - ) - - interfaces_lines = list_interfaces_process.stdout.splitlines() + universal_newlines=True) - interface_names = [x.split()[1] for x in interfaces_lines] + interface_names = (x.split()[1] for x in proc.stdout.splitlines()) for interface_name in interface_names: - interface_introspection_run = run( + proc = run( args=[executable.absolute(), '--bus-introspect', interface_name], stdout=PIPE, check=True, - universal_newlines=True, - ) + universal_newlines=True) interface_file_name = output_dir / (interface_name + '.xml') - with open(interface_file_name, mode='w') as f: - f.write(interface_introspection_run.stdout) + interface_file_name.write_text(proc.stdout) interface_file_name.chmod(0o644) - -def iterate_executables(output_dir, executables): - output_dir.mkdir(mode=0o755, exist_ok=True) - - for exe in executables: - extract_interfaces_xml(output_dir, exe) - - def main(): parser = ArgumentParser() - - parser.add_argument( - 'output', - type=Path, - ) - - parser.add_argument( - 'executables', - type=Path, - nargs='+', - ) + parser.add_argument('output', + type=Path) + parser.add_argument('executables', + nargs='+', + type=Path) args = parser.parse_args() - iterate_executables(args.output, args.executables) - + args.output.mkdir(exist_ok=True) + for exe in args.executables: + extract_interfaces_xml(args.output, exe) if __name__ == '__main__': main() |