]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
device: simplify device_found_to_string_many() a tiny bit
authorLennart Poettering <lennart@poettering.net>
Tue, 5 Jun 2018 15:22:11 +0000 (17:22 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 Jun 2018 13:28:50 +0000 (15:28 +0200)
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

index e92b982439fac404e6a474c2552abdd9a93c9793..21e90b8655c4fd01afc387619d9bbd7b2de8a215 100644 (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;