]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: simplify the loop in lists_driver_lookup_name()
authorMasahiro Yamada <yamada.m@jp.panasonic.com>
Sun, 28 Sep 2014 13:52:27 +0000 (22:52 +0900)
committerSimon Glass <sjg@chromium.org>
Wed, 22 Oct 2014 16:32:16 +0000 (10:32 -0600)
if (strncmp(name, entry->name, len))
                continue;

        /* Full match */
        if (len == strlen(entry->name))
                return entry;

is equivalent to:

        if (!strcmp(name, entry->name))
                return entry;

The latter is simpler.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
drivers/core/lists.c

index 699f94b435f213a0e78e91e4d2e854ae45473e7b..3a1ea8565449699a39ba5684dbecfbf71e30780b 100644 (file)
@@ -24,19 +24,12 @@ struct driver *lists_driver_lookup_name(const char *name)
                ll_entry_start(struct driver, driver);
        const int n_ents = ll_entry_count(struct driver, driver);
        struct driver *entry;
-       int len;
 
        if (!drv || !n_ents)
                return NULL;
 
-       len = strlen(name);
-
        for (entry = drv; entry != drv + n_ents; entry++) {
-               if (strncmp(name, entry->name, len))
-                       continue;
-
-               /* Full match */
-               if (len == strlen(entry->name))
+               if (!strcmp(name, entry->name))
                        return entry;
        }