From ce12bd19a0d7fc362d6bced70601a26883d53b0a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 5 Aug 2024 12:26:53 +0900 Subject: udevadm-info: trival cleanups - drop trailing an empty line, - use FOREACH_ARRAY() macro, - add short comment for boolean argument. --- src/udev/udevadm-info.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/udev') 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; } -- cgit v1.2.3