[FFmpeg-devel] [PATCH 1/3] avformat/libquvi: fix error handling
Gilles Chanteperdrix
gilles.chanteperdrix at xenomai.org
Wed Apr 8 21:46:30 CEST 2015
On Wed, Apr 08, 2015 at 09:13:11PM +0200, Michael Niedermayer wrote:
> On Wed, Apr 08, 2015 at 07:16:36PM +0200, Gilles Chanteperdrix wrote:
> > avoid calling cleanup functions on uninitialized variables
> >
> > Signed-off-by: Gilles Chanteperdrix <gilles.chanteperdrix at xenomai.org>
> > ---
> > libavformat/libquvi.c | 41 +++++++++++++++++++++++++----------------
> > 1 file changed, 25 insertions(+), 16 deletions(-)
> >
> > diff --git a/libavformat/libquvi.c b/libavformat/libquvi.c
> > index 7c5f7a2..e838b34 100644
> > --- a/libavformat/libquvi.c
> > +++ b/libavformat/libquvi.c
> > @@ -63,28 +63,38 @@ static int libquvi_read_header(AVFormatContext *s)
> > char *media_url, *pagetitle;
> >
> > rc = quvi_init(&q);
> > - if (rc != QUVI_OK)
> > - goto quvi_fail;
> > + if (rc != QUVI_OK) {
> > + av_log(s, AV_LOG_ERROR, "%s\n", quvi_strerror(q, rc));
> > + return AVERROR_EXTERNAL;
> > + }
>
> is quvi_strerror() thread safe ?
I do not know, it was called in the original code, simply moved it
around.
Looking at the code, it would seem it is reentrant, with the state
in quvi_t, so as long as the quvi_t is not moved around thread, this
should be thread-safe.
char *quvi_strerror(quvi_t session, QUVIcode code)
{
static const char *errormsgs[] =
{
"no error",
"memory allocation failed",
"bad handle argument to function",
"invalid argument to function",
"curl initialization failed",
"end of list iteration",
"aborted by callback",
"lua initilization failed",
"lua website scripts not found",
"lua util scripts not found",
"invalid error code (internal _INTERNAL_QUVI_LAST)"
};
_quvi_t quvi = (_quvi_t) session;
if (quvi)
{
if (code > _INTERNAL_QUVI_LAST)
return (quvi->errmsg);
}
else
{
if (code > _INTERNAL_QUVI_LAST)
code = _INTERNAL_QUVI_LAST;
}
return ((char *)errormsgs[code]);
}
--
Gilles.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150408/b6817070/attachment.asc>
More information about the ffmpeg-devel
mailing list