From 94f7ee9770161604c60dd0949c65173ca34d774f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 22 Mar 2022 08:44:44 +0100 Subject: [PATCH 1/5] man: clarify that options set the message fields and are not derived from them --- man/systemd.network.xml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 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:: BootServerAddress= - Takes an IPv4 address of the boot server used by e.g. PXE boot systems. When specified, - the address is set to the siaddr field of the DHCP message header. See - RFC 2131 for more details. - Defaults to unset. + Takes an IPv4 address of the boot server used by e.g. PXE boot systems. When specified, this + address is sent in the field of the DHCP message header. See RFC 2131 for more details. Defaults to + unset. @@ -2640,13 +2640,13 @@ Token=prefixstable:2002:da8:1:: BootServerName= - 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 - RFC 2132 for more details. - Defaults to unset. - Note that typically one of - BootServerName=/BootServerAddress= is sufficient to be - set, but both can be set too, if desired. + 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 RFC 2132 for more details. Defaults to + unset. + + Note that typically setting one of BootServerName= or + BootServerAddress= is sufficient, but both can be set too, if desired. @@ -2654,10 +2654,10 @@ Token=prefixstable:2002:da8:1:: BootFilename= - 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 - RFC 2132 for more details. - Defaults to unset. + 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 RFC 2132 for more details. Defaults to + unset. From 3b9d38f5c8711f138456e65aec3b69c55ed1ea19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 22 Mar 2022 10:10:39 +0100 Subject: [PATCH 2/5] tools/dbus_exporter: deblackify and shorten code a bit When we do mkdir, we should just use 0o777 and let the umask take care of the rest. Specifying an explicit mode is inappropriate. And when touching the code, let's replace black madness with normal python style. --- tools/dbus_exporter.py | 47 +++++++++++++----------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) 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, - ) + universal_newlines=True) - interfaces_lines = list_interfaces_process.stdout.splitlines() - - 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() From dba8ef106e17cef058c0b7d9c6b8830e9f1943a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 22 Mar 2022 10:43:03 +0100 Subject: [PATCH 3/5] sd-bus: use _cleanup_ in one more place --- src/libsystemd/sd-bus/bus-objects.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) 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)); From 16568fd3362f7d9cc1871a703cfb91b393753395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 22 Mar 2022 14:02:47 +0100 Subject: [PATCH 4/5] errno-to-awk: simplify expression No functional change. --- src/basic/errno-to-name.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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{ From 5cad4c70e34322aaf07202c94fbc36839f638016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 22 Mar 2022 14:05:37 +0100 Subject: [PATCH 5/5] homework: s/EWOULDBLOCK/EAGAIN/ C.f. 012d7b4217420163db5752a63da6cab39d25edf3, ff55c3c7327e6ad8ab139aef52d498386d4f4a72, ca2031fcc863fcdd4dd1594709918cb60cfd0e1b. --- src/home/homework-luks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);