On Mon, Jun 04, 2012 at 01:55:10PM +0300, Dan Carpenter wrote:
> On Mon, Jun 04, 2012 at 11:36:11AM +0200, Lars-Peter Clausen wrote:
> > +ssize_t iio_enum_available_read(struct iio_dev *indio_dev,
> > + uintptr_t priv, const struct iio_chan_spec *chan, char *buf)
> > +{
> > + const struct iio_enum *e = (const struct iio_enum *)priv;
> > + unsigned int i;
> > + size_t len = 0;
> > +
> > + if (!e->num_items)
> > + return 0;
> > +
> > + for (i = 0; i < e->num_items; ++i)
> > + len += snprintf(buf + len, PAGE_SIZE - len, "%s ", e->items[i]);
> > +
> > + /* replace last space with a newline */
> > + buf[len - 1] = '\n';
> > +
>
> It would be better to use scnprintf() here instead of snprintf().
> snprintf() returns the number of characters that would have been
> printed if there were space (not counting the NULL), so len - 1 can
> be beyond the end of the array.
Good idea. Lars, care to send a follow-on patch that fixes this up?
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Linux USB Devel]
[Video for Linux]
[Linux Audio Users]
[Photo]
[Yosemite News]
[Yosemite Photos]
[Free Online Dating]
[Linux Kernel]
[Linux SCSI]
[XFree86]