From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-media@vger.kernel.org,
Kieran Bingham <kieran.bingham@ideasonboard.com>
Subject: Re: [PATCH yavta 6/7] Support setting control from values stored in a file
Date: Fri, 22 Feb 2019 13:47:39 +0200 [thread overview]
Message-ID: <20190222114739.GS3522@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20190220212651.dvwwjd4glylhfvtb@valkosipuli.retiisi.org.uk>
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@ideasonboard.com>
> > ---
> > 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 ?
> > + if (size != (ssize_t)ctrl->size) {
> > + printf("error reading control file `%s' (%s)\n", val,
> > + strerror(errno));
> > + close(fd);
> > + return -EINVAL;
> > + }
> > +
> > + close(fd);
> > + return 0;
> > + }
> > +
> > if (*val++ != '{')
> > return -EINVAL;
> >
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2019-02-22 11:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 12:51 [PATCH yavta 0/7] Compound controls and controls reset support Laurent Pinchart
2019-02-20 12:51 ` [PATCH yavta 1/7] yavta: Refactor video_list_controls() Laurent Pinchart
2019-02-20 13:21 ` Sakari Ailus
2019-02-20 14:07 ` Laurent Pinchart
2019-02-20 14:13 ` Sakari Ailus
2019-02-20 12:51 ` [PATCH yavta 2/7] Implement VIDIOC_QUERY_EXT_CTRL support Laurent Pinchart
2019-02-20 12:51 ` [PATCH yavta 3/7] Implement compound control get support Laurent Pinchart
2019-02-20 14:06 ` Sakari Ailus
2019-02-20 14:55 ` Laurent Pinchart
2019-02-20 21:16 ` Sakari Ailus
2019-02-20 12:51 ` [PATCH yavta 4/7] Implement compound control set support Laurent Pinchart
2019-02-20 21:21 ` Sakari Ailus
2019-02-20 12:51 ` [PATCH yavta 5/7] Add support to reset device controls Laurent Pinchart
2019-02-20 12:51 ` [PATCH yavta 6/7] Support setting control from values stored in a file Laurent Pinchart
2019-02-20 21:26 ` Sakari Ailus
2019-02-22 11:47 ` Laurent Pinchart [this message]
2019-02-22 12:32 ` Sakari Ailus
2019-02-20 12:51 ` [PATCH yavta 7/7] Remove unneeded conditional compilation for old V4L2 API versions Laurent Pinchart
2019-02-20 21:33 ` [PATCH yavta 0/7] Compound controls and controls reset support Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190222114739.GS3522@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox