Re: [RFC PATCH v2] Xilinx AXI-Stream FIFO v4.1 IP core driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux