[FFmpeg-devel] [PATCH 1/6] Return meaningful error codes, rather than always -1.
Stefano Sabatini
stefano.sabatini-lala
Sun Apr 25 20:32:48 CEST 2010
On date Sunday 2010-04-25 15:55:29 +0100, M?ns Rullg?rd encoded:
> Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:
>
> > On date Sunday 2010-04-25 10:49:50 +0200, Luca Abeni encoded:
> >> Hi,
> >>
> >>
> >> On Sat, 2010-04-24 at 20:53 +0200, Stefano Sabatini wrote:
> >> > ---
> >> > libavdevice/v4l2.c | 34 +++++++++++++++++-----------------
> >> > 1 files changed, 17 insertions(+), 17 deletions(-)
> >> >
> >> > diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> >> [...]
> >>
> >> the "return -1 ---> return AVERROR(errno)" changes look ok, but I am not
> >> sure if the following change is correct:
> >> > + return AVERROR(errno);
> >> > }
> >> > if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
> >> > av_log(ctx, AV_LOG_ERROR, "Not a video capture device\n");
> >> > close(fd);
> >> >
> >> > - return -1;
> >> > + return AVERROR(ENOSYS);
> >
> > I was unsure between this and EPERM = "Operation not permitted".
> >
> > EPERM = -1 so it should be safe to just replace -1 with
> > AVERROR(EPERM), would that be fine?
>
> Not for that reason. This is certainly not a problem of lack of
> permissions. Capturing from something which is not a capture device
> is impossible no matter what permissions you have. How about ENODEV?
From:
http://www.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_03.html
[ENODEV] No such device. An attempt was made to apply an inappropriate
function to a device; for example, trying to read a write-only device
such as a printer.
Looks fine, and yes better than:
[EPERM] Operation not permitted. An attempt was made to perform an
operation limited to processes with appropriate privileges or to the
owner of a file or other resource.
[...]
Regards.
--
FFmpeg = Fascinating Fabulous Minimal Portentous Enhancing Governor
More information about the ffmpeg-devel
mailing list