[FFmpeg-devel] [PATCH] Make cmdutils.c:print_error() use strerror() if av_strerror() fails (e.g. if strerror_r() is not defined)

Stefano Sabatini stefano.sabatini-lala
Wed May 5 00:37:52 CEST 2010


On date Tuesday 2010-05-04 17:12:24 +0200, Michael Niedermayer encoded:
> On Tue, May 04, 2010 at 03:41:46PM +0200, Stefano Sabatini wrote:
[...]
> > > > Subject: [PATCH 2/3] Make print_error() use strerror() in case av_strerror() fails.
> > > > 
> > > > Should provide a meaningful error message for systems which do not
> > > > support strerror_r().
> > > > 
> > > > Fix roundup issue #1894.
> > > > ---
> > > >  cmdutils.c |    6 ++++--
> > > >  1 files changed, 4 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/cmdutils.c b/cmdutils.c
> > > > index e6efc49..0de1d2d 100644
> > > > --- a/cmdutils.c
> > > > +++ b/cmdutils.c
> > > > @@ -300,8 +300,10 @@ void print_error(const char *filename, int err)
> > > >          break;
> > > >  #endif
> > > >      default:
> > > > -        av_strerror(err, errbuf, sizeof(errbuf));
> > > > -        fprintf(stderr, "%s: %s\n", filename, errbuf);
> > > > +        if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
> > > > +            fprintf(stderr, "%s: %s\n", filename, strerror(AVUNERROR(err)));
> > > > +        else
> > > > +            fprintf(stderr, "%s: %s\n", filename, errbuf);
> > > 
> > > missing {} and you should document the thread saftey issues tis introduces
> > > users of the code likely want to know
> > 
> > Uhm it's a cmdutils.c function, I don't think we need to document
> > this. Note also that the usage in ffplay of print_error() looks safe
> > anyway, since print_error() is used only in the init phase, with just
> > one active thread.
> 
> you need to document it if you want me to approve it ;)

Revisited patch and documentation for print_error() attached.

Regards.
-- 
FFmpeg = Fiendish and Friendly Multimedia Purposeless Ecumenical God



More information about the ffmpeg-devel mailing list