On Do, 2019-03-28 at 16:50 +0300, Dan Carpenter wrote:
> External E-Mail
> 
> 
> On Thu, Mar 28, 2019 at 02:17:29PM +0100, Christian Gromm wrote:
> > 
> > +static ssize_t mdev_link_direction_store(struct config_item *item,
> > +                                    const char *page, size_t
> > count)
> > +{
> > +   struct mdev_link *mdev_link = to_mdev_link(item);
> > +
> > +   if (sysfs_streq(page, "dir_rx") && sysfs_streq(page, "rx")
> > &&
> > +       sysfs_streq(page, "dir_tx") && sysfs_streq(page,
> > "tx"))
> These tests are reversed.  It will never return -EINVAL because one
> string can't be four things.

OMG, that was braindead. Sorry for the inconvenience. I'll fix that up.

thanks,
Chris

> 
>       if (!sysfs_streq(page, "dir_rx") && !sysfs_streq(page, "rx") &&
>           !sysfs_streq(page, "dir_tx") && !sysfs_streq(page, "tx"))
>               return -EINVAL;
> 
> The sysfs_streq() return true if the strings are equal.  The strcmp()
> functions less intuitive and they should be used like this:
> 
>       if (strcmp(foo, bar) < 0) {  // <-- foo < bar
>       if (strcmp(foo, bar) != 0) { // <-- foo != bar
>       if (strcmp(foo, bar) == 0) { // <-- foo == bar
> 
> The other streq() tests have the same issue.
> 
> regards,
> dan carpenter
> 
> 
_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to