From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tuukka Toivonen <tuukka.toivonen@intel.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [yavta PATCH] Return proper error code if STREAMON fails
Date: Sat, 12 Dec 2015 17:40:07 +0200 [thread overview]
Message-ID: <2149558.6ozUHQXHtS@avalon> (raw)
In-Reply-To: <207011196.fyjkdD1C8L@ttoivone-desk1>
Hi Tuukka,
Thank you for the patch.
On Monday 30 November 2015 16:46:17 Tuukka Toivonen wrote:
> Fix the bug causing success to be returned even if VIDIOC_STREAMON
> failed. Also check returned error from VIDIOC_STREAMOFF.
>
> Signed-off-by: Tuukka Toivonen <tuukka.toivonen@intel.com>
> ---
> yavta.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/yavta.c b/yavta.c
> index b627725..3ad1c97 100644
> --- a/yavta.c
> +++ b/yavta.c
> @@ -1623,7 +1623,7 @@ static int video_do_capture(struct device *dev,
> unsigned int nframes,
> unsigned int i;
> double bps;
> double fps;
> - int ret;
> + int ret, ret2;
>
> /* Start streaming. */
> ret = video_enable(dev, 1);
> @@ -1708,7 +1708,9 @@ static int video_do_capture(struct device *dev,
> unsigned int nframes,
> }
>
> /* Stop streaming. */
> - video_enable(dev, 0);
> + ret = video_enable(dev, 0);
> + if (ret < 0)
> + goto done;
>
> if (nframes == 0) {
> printf("No frames captured.\n");
> @@ -1732,7 +1734,11 @@ static int video_do_capture(struct device *dev,
> unsigned int nframes,
> i, ts.tv_sec, ts.tv_nsec/1000, fps, bps);
>
> done:
> - return video_free_buffers(dev);
> + ret2 = video_free_buffers(dev);
I wonder if there's really a point calling video_free_buffers() in the error
case. The function will return an error causing the caller to close the
device, which will free the buffers. There are other locations in yavta after
buffers are allocated where the buffers are not freed in the error path. What
would you think of just replacing the goto done statements by a return ret ?
> + if (ret >= 0)
> + ret = ret2;
> +
> + return ret;
> }
>
> #define V4L_BUFFERS_DEFAULT 8
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2015-12-12 15:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-30 14:46 [yavta PATCH] Return proper error code if STREAMON fails Tuukka Toivonen
2015-12-12 15:40 ` Laurent Pinchart [this message]
2015-12-14 7:16 ` Tuukka Toivonen
2015-12-14 7:49 ` [yavta PATCH v2] " Tuukka Toivonen
2015-12-14 18:40 ` Laurent Pinchart
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=2149558.6ozUHQXHtS@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=tuukka.toivonen@intel.com \
/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