summaryrefslogtreecommitdiffstats
path: root/src/udev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-08-05 05:26:53 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-08-05 05:27:10 +0200
commitce12bd19a0d7fc362d6bced70601a26883d53b0a (patch)
tree1e5650803514a0c299300c3598d84bf4686e416c /src/udev
parentsleep: add HibernateOnACPower= option (#33846) (diff)
downloadsystemd-ce12bd19a0d7fc362d6bced70601a26883d53b0a.tar.xz
systemd-ce12bd19a0d7fc362d6bced70601a26883d53b0a.zip
udevadm-info: trival cleanups
- drop trailing an empty line, - use FOREACH_ARRAY() macro, - add short comment for boolean argument.
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udevadm-info.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index 2cdc3bd305..1a0e2656ce 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -98,6 +98,9 @@ static int print_all_attributes(sd_device *device, bool is_parent) {
assert(device);
+ if (is_parent)
+ puts("");
+
value = NULL;
(void) sd_device_get_devpath(device, &value);
printf(" looking at %sdevice '%s':\n", is_parent ? "parent " : "", strempty(value));
@@ -150,10 +153,8 @@ static int print_all_attributes(sd_device *device, bool is_parent) {
typesafe_qsort(sysattrs, n_items, sysattr_compare);
- for (size_t i = 0; i < n_items; i++)
- printf(" %s{%s}==\"%s\"\n", is_parent ? "ATTRS" : "ATTR", sysattrs[i].name, sysattrs[i].value);
-
- puts("");
+ FOREACH_ARRAY(i, sysattrs, n_items)
+ printf(" %s{%s}==\"%s\"\n", is_parent ? "ATTRS" : "ATTR", i->name, i->value);
return 0;
}
@@ -172,12 +173,12 @@ static int print_device_chain(sd_device *device) {
"and the attributes from one single parent device.\n"
"\n");
- r = print_all_attributes(device, false);
+ r = print_all_attributes(device, /* is_parent = */ false);
if (r < 0)
return r;
for (child = device; sd_device_get_parent(child, &parent) >= 0; child = parent) {
- r = print_all_attributes(parent, true);
+ r = print_all_attributes(parent, /* is_parent = */ true);
if (r < 0)
return r;
}