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.
This commit is contained in:
Lennart Poettering 2018-06-05 17:22:11 +02:00
parent f0831ed2a0
commit 69ce73d18d
1 changed files with 2 additions and 3 deletions

View File

@ -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;