v4l2: Unify one instance of reading/storing errno

Message ID 1415605926-88843-1-git-send-email-martin@martin.st
State Committed
Commit b776113e5d4a56759615196de98efe802e95a6b6
Headers show

Commit Message

Martin Storsjö Nov. 10, 2014, 7:52 a.m.
---
 libavdevice/v4l2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Luca Barbato Nov. 10, 2014, 9:09 a.m. | #1
On 10/11/14 08:52, Martin Storsjö wrote:
> ---
>   libavdevice/v4l2.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> index fdec0ec..302639d 100644
> --- a/libavdevice/v4l2.c
> +++ b/libavdevice/v4l2.c
> @@ -348,14 +348,14 @@ static int mmap_init(AVFormatContext *ctx)
>
>       res = ioctl(s->fd, VIDIOC_REQBUFS, &req);
>       if (res < 0) {
> -        res = errno;
> -        if (errno == EINVAL) {
> +        res = AVERROR(errno);
> +        if (res == AVERROR(EINVAL)) {
>               av_log(ctx, AV_LOG_ERROR, "Device does not support mmap\n");
>           } else {
>               av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_REQBUFS)\n");
>           }
>
> -        return AVERROR(res);
> +        return res;
>       }
>
>       if (req.count < 2) {
>

Ok.

Patch

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index fdec0ec..302639d 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -348,14 +348,14 @@  static int mmap_init(AVFormatContext *ctx)
 
     res = ioctl(s->fd, VIDIOC_REQBUFS, &req);
     if (res < 0) {
-        res = errno;
-        if (errno == EINVAL) {
+        res = AVERROR(errno);
+        if (res == AVERROR(EINVAL)) {
             av_log(ctx, AV_LOG_ERROR, "Device does not support mmap\n");
         } else {
             av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_REQBUFS)\n");
         }
 
-        return AVERROR(res);
+        return res;
     }
 
     if (req.count < 2) {