Hi Laurent, On Fri, Feb 22, 2019 at 01:47:39PM +0200, Laurent Pinchart wrote: > Hi Sakari, > > On Wed, Feb 20, 2019 at 11:26:52PM +0200, Sakari Ailus wrote: > > On Wed, Feb 20, 2019 at 02:51:22PM +0200, Laurent Pinchart wrote: > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> > > > --- > > > yavta.c | 25 +++++++++++++++++++++++++ > > > 1 file changed, 25 insertions(+) > > > > > > diff --git a/yavta.c b/yavta.c > > > index 1490878c6f7e..2d49131a4271 100644 > > > --- a/yavta.c > > > +++ b/yavta.c > > > @@ -1334,6 +1334,31 @@ static int video_parse_control_array(const struct v4l2_query_ext_ctrl *query, > > > __u32 value; > > > > > > for ( ; isspace(*val); ++val) { }; > > > + > > > + if (*val == '<') { > > > + /* Read the control value from the given file. */ > > > + ssize_t size; > > > + int fd; > > > + > > > + val++; > > > + fd = open(val, O_RDONLY); > > > + if (fd < 0) { > > > + printf("unable to open control file `%s'\n", val); > > > + return -EINVAL; > > > + } > > > + > > > + size = read(fd, ctrl->ptr, ctrl->size); > > > > Note that a read of count reads *up to* count number of bytes from the file > > descriptor. In other words, it's perfectly correct for it to read less than > > requested. > > > > How about using fread(3) instead? Or changing this into a loop? > > Do you expect this to cause issues in practice ? When does read() return > less data than requested for regular files ? API-wise there's no guarantee. This could simply fail for someone at some point when reading a largish compound control. Also try reading from e.g. /dev/random. :-) -- Sakari Ailus