[FFmpeg-devel] [PATCH 2/6] Implement IOCTL_ERROR macro and use it.

Stefano Sabatini stefano.sabatini-lala
Sun Apr 25 20:01:57 CEST 2010


On date Sunday 2010-04-25 10:52:41 +0200, Luca Abeni encoded:
> Hi,
> 
> On Sat, 2010-04-24 at 20:53 +0200, Stefano Sabatini wrote:
> [...] 
> > +#define IOCTL_ERROR(ctx__, ioctl__) av_log(ctx__, AV_LOG_ERROR, "ioctl(" #ioctl__ "): %s\n", strerror(errno))
> > +
> >  static int device_open(AVFormatContext *ctx, uint32_t *capabilities)
> >  {
> >      struct v4l2_capability cap;
> > @@ -177,8 +179,7 @@ static int device_open(AVFormatContext *ctx, uint32_t *capabilities)
> >          return AVERROR(errno);
> >      }
> >      if (res < 0) {
> > -        av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n",
> > -                 strerror(errno));
> > +        IOCTL_ERROR(ctx, VIDIOC_QUERYCAP);
> 
> I am not sure if this kind of changes really improve the readability.

I generalized the previous patch, now we have a log_errno() function
which is used whenever we need to print the string corresponding to an
errno.

Also it simplify the use of av_strerror() rather than strerror(),
which is not thread-safe so should not be used.

I believe this change allows to increase consistency (for example in
the current code there sometimes we print the error string, sometimes
not), and decreases the chance to add non-consistent or wrong code.

Regards.
-- 
FFmpeg = Free and Fundamentalist Mystic Philosofic Efficient Game



More information about the ffmpeg-devel mailing list