At Fri, 13 Sep 2013 15:06:33 +0200,
Marin Ramesa wrote:
>
> On 13.09.2013 14:42:44, Neal H. Walfield wrote:
> > At Fri, 13 Sep 2013 13:31:53 +0200,
> > Marin Ramesa wrote:
> > > diff --git a/device/dev_name.c b/device/dev_name.c
> > > index bf541df..6ce4b19 100644
> > > --- a/device/dev_name.c
> > > +++ b/device/dev_name.c
> > > @@ -69,9 +69,12 @@ name_equal(src, len, target)
> > > int len;
> > > char *target;
> > > {
> > > - while (--len >= 0)
> > > + while (--len >= 0) {
> > > if (*src++ != *target++)
> > > return FALSE;
> > > + if (*src == '\0' && *target != '\0')
> > > + return FALSE;
> > > + }
> >
> > Shouldn't this return TRUE?
> >
> > Neal
>
> I don't think so. The function tests if 'src' and 'target' are equal
> for 'len' characters, so if 'src' null-terminates inside the loop and
> 'target' doesn't, it means that they are not equal (btw in the comments
> it says that 'target' is sure to be null-terminated).
This is clearer, I think:
if (*src == '\0' || *target == '\0')
return (*src == '\0' && *target == '\0');