From: Masahiro Yamada Date: Sun, 28 Sep 2014 13:52:27 +0000 (+0900) Subject: dm: simplify the loop in lists_driver_lookup_name() X-Git-Tag: v2015.01-rc1~208^2~62 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2cede453dadae5bacd9c659704029bf81e7b06a0;p=oweals%2Fu-boot.git dm: simplify the loop in lists_driver_lookup_name() 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 Acked-by: Simon Glass Acked-by: Igor Grinberg --- diff --git a/drivers/core/lists.c b/drivers/core/lists.c index 699f94b435..3a1ea85654 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -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; }