[FFmpeg-devel] [PATCH] libavdevice/v4l2: fix of crash caused by assert

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Sep 1 23:21:47 CEST 2014


On Mon, Sep 01, 2014 at 11:00:14PM +0200, Giorgio Vazzana wrote:
> 2014-09-01 22:46 GMT+02:00 Reimar Döffinger <Reimar.Doeffinger at gmx.de>:
> > On Mon, Sep 01, 2014 at 10:33:15PM +0200, Giorgio Vazzana wrote:
> >> +static int enqueue_buffer(struct video_data *s, struct v4l2_buffer *buf)
> >> +{
> >> +    int res = 0;
> >> +
> >> +    if (v4l2_ioctl(s->fd, VIDIOC_QBUF, buf) < 0) {
> >> +        res = AVERROR(errno);
> >> +        av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n", av_err2str(res));
> >> +    } else {
> >> +        avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
> >> +    }
> >> +
> >> +    return res;
> >
> > Nit: I'd prefer something simpler that avoids cluttering the normal path
> > because of error handling like:
> >
> >> +    if (v4l2_ioctl(s->fd, VIDIOC_QBUF, buf) < 0) {
> >> +        av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n", av_err2str(res));
> >> +        return AVERROR(errno);
> 
> If we call av_log(), errno is not guaranteed to be the same after the
> call. Also, av_err2str() needs AVERROR(errno).

Hmm...

if (v4l2_ioctl(s->fd, VIDIOC_QBUF, buf) < 0) {
   int res = AVERROR(errno);
   av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n", av_err2str(res));
   return res;
}
avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
return 0;

Yeah, I guess then it's not really better than your variant anymore,
so whatever you want.
I haven't reviewed it all that well, but in principle the patch looks
good to me, but it might be better to wait until we get a test result?


More information about the ffmpeg-devel mailing list