Hi Masahiro, On 28 September 2014 07:52, Masahiro Yamada <yamad...@jp.panasonic.com> wrote: > 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 <yamad...@jp.panasonic.com> > --- > > drivers/core/lists.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/drivers/core/lists.c b/drivers/core/lists.c > index 699f94b..3a1ea85 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; > }
The discussion on this was here: http://lists.denx.de/pipermail/u-boot/2014-September/189336.html I don't see a lot of value in the extra code, so I think we should take this patch. If it is found to be a problem, we can go back to the defensive code and add a test case so it is clear what exactly we are defending against. Acked-by: Simon Glass <s...@chromium.org> Regards, Simon _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot