[U-Boot] A minor question on a Driver Model function
Masahiro Yamada
yamada.m at jp.panasonic.com
Wed Sep 17 10:18:56 CEST 2014
Hi Igor,
On Mon, 15 Sep 2014 11:04:20 +0300
Igor Grinberg <grinberg at compulab.co.il> wrote:
> Hi,
>
> On 09/14/14 21:28, Simon Glass wrote:
> > Hi Masahiro,
> >
> > On 12 September 2014 05:25, Masahiro Yamada <yamada.m at jp.panasonic.com> wrote:
> >> Hi Simon,
> >>
> >>
> >> I have a qustion about lists_driver_lookup_name() function.
> >>
> >>
> >>
> >> for (entry = drv; entry != drv + n_ents; entry++) {
> >> if (strncmp(name, entry->name, len))
> >> continue;
> >>
> >> /* Full match */
> >> if (len == strlen(entry->name))
> >> return entry;
> >> }
> >>
> >>
> >>
> >>
> >> Why is this not like follows?
> >>
> >>
> >>
> >>
> >> for (entry = drv; entry != drv + n_ents; entry++) {
> >> if (!strcmp(name, entry->name))
> >> return entry;
> >> }
>
> I would suggest still using strncmp as it is safer,
> but count also the '\0', so something like:
Why safer?
Could you give me more detailed explanation?
Best Regards
Masahiro Yamada
More information about the U-Boot
mailing list