On Tue, Jul 17, 2018 at 12:13:40PM +0300, Dan Carpenter wrote:
> > +static ssize_t sysfs_read(struct device *dev, char *buf,
> > + unsigned int addr_offset)
> > +{
> > + struct axis_fifo *fifo = dev_get_drvdata(dev);
> > + unsigned int read_val;
> > + unsigned int strlen;
> > + char tmp[32];
> > +
> > + read_val = ioread32(fifo->base_addr + addr_offset);
> > +
> > + strlen = snprintf(tmp, 32, "0x%08x\n", read_val);
^^
Get rid of this magic number. Use sizeof(tmp).
> > + if (strlen < 0)
> > + return -EINVAL;
>
> Kernel snprintf() won't ever return error codes, so this check is not
> required... Just delete it. Or at least preserve the error code.
>
Also strlen is unsigned. Plus it's the wrong thing to name it the same
as the function strlen(). Just call it "len".
regards,
dan carpenter
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel