From 69ce73d18d474f3531e52ade69a2a4725466888f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 5 Jun 2018 17:22:11 +0200 Subject: [PATCH] device: simplify device_found_to_string_many() a tiny bit No need to maintain a NULL marker at the end of the table if we know the size of the array anyway. --- src/core/device.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/device.c b/src/core/device.c index e92b982439..21e90b8655 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -157,7 +157,6 @@ static const struct { { DEVICE_FOUND_UDEV_DB, "found-udev-db" }, { DEVICE_FOUND_MOUNT, "found-mount" }, { DEVICE_FOUND_SWAP, "found-swap" }, - {} }; static int device_found_to_string_many(DeviceFound flags, char **ret) { @@ -166,7 +165,7 @@ static int device_found_to_string_many(DeviceFound flags, char **ret) { assert(ret); - for (i = 0; device_found_map[i].name; i++) { + for (i = 0; i < ELEMENTSOF(device_found_map); i++) { if (!FLAGS_SET(flags, device_found_map[i].flag)) continue; @@ -196,7 +195,7 @@ static int device_found_from_string_many(const char *name, DeviceFound *ret) { if (r == 0) break; - for (i = 0; device_found_map[i].name; i++) + for (i = 0; i < ELEMENTSOF(device_found_map); i++) if (streq(word, device_found_map[i].name)) { f = device_found_map[i].flag; break;