[FFmpeg-devel] [PATCH] Make nutdec return meaningful error codes.

Stefano Sabatini stefano.sabatini-lala
Wed Jan 12 17:38:51 CET 2011


On date Wednesday 2011-01-12 15:10:05 +0100, Michael Niedermayer encoded:
> On Tue, Jan 11, 2011 at 11:56:15PM +0100, Stefano Sabatini wrote:
> > On date Friday 2010-12-31 21:30:19 +0100, Michael Niedermayer encoded:
> > > On Tue, Dec 28, 2010 at 02:32:44AM +0100, Stefano Sabatini wrote:
> > > > ---
> > > >  libavformat/nutdec.c |   62 +++++++++++++++++++++++++-------------------------
> > > >  1 files changed, 31 insertions(+), 31 deletions(-)
> > > > 
> > > > diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
> > > > index d5d7c2b..ee953d5 100644
> > > > --- a/libavformat/nutdec.c
> > > > +++ b/libavformat/nutdec.c
> > > > @@ -49,7 +49,7 @@ static int get_str(ByteIOContext *bc, char *string, unsigned int maxlen){
> > > >          string[FFMIN(len, maxlen-1)]= 0;
> > > >  
> > > >      if(maxlen == len)
> > > > -        return -1;
> > > > +        return AVERROR(EINVAL);
> > > >      else
> > > >          return 0;
> > > >  }
> > > > @@ -66,7 +66,7 @@ static uint64_t get_fourcc(ByteIOContext *bc){
> > > >  
> > > >      if     (len==2) return get_le16(bc);
> > > >      else if(len==4) return get_le32(bc);
> > > > -    else            return -1;
> > > > +    else            return AVERROR(EINVAL);
> > > >  }
> > > >  
> > > >  #ifdef TRACE
> > > 
> > > These error codes are wrong
> > > 
> > > [...]
> > > > @@ -142,7 +142,7 @@ static uint64_t find_any_startcode(ByteIOContext *bc, int64_t pos){
> > > >   * Find the given startcode.
> > > >   * @param code the startcode
> > > >   * @param pos the start position of the search, or -1 if the current position
> > > > - * @return the position of the startcode or -1 if not found
> > > > + * @return the position of the startcode or AVERROR(EINVAL) if not found
> > > >   */
> > > >  static int64_t find_startcode(ByteIOContext *bc, uint64_t code, int64_t pos){
> > > >      for(;;){
> > > > @@ -150,7 +150,7 @@ static int64_t find_startcode(ByteIOContext *bc, uint64_t code, int64_t pos){
> > > >          if(startcode == code)
> > > >              return url_ftell(bc) - 8;
> > > >          else if(startcode == 0)
> > > > -            return -1;
> > > > +            return AVERROR(EINVAL);
> > > >          pos=-1;
> > > >      }
> > > >  }
> > > 
> > > rejected
> > > 
> > > 
> > > [...]
> > > > @@ -179,7 +179,7 @@ static int skip_reserved(ByteIOContext *bc, int64_t pos){
> > > >      pos -= url_ftell(bc);
> > > >      if(pos<0){
> > > >          url_fseek(bc, pos, SEEK_CUR);
> > > > -        return -1;
> > > > +        return pos;
> > > >      }else{
> > > >          while(pos--)
> > > >              get_byte(bc);
> > > 
> > > this introduces a bug nothing else
> > 
> > Sorry the patch was sloppy, hope this will be fine.
> > -- 
> > FFmpeg = Faithless & Faithless Mystic Philosofic Excellent Ghost
> 
> >  nutdec.c |   28 ++++++++++++++--------------
> >  1 file changed, 14 insertions(+), 14 deletions(-)
> > 12bd208088f044ec8b358179bca6adf2976aded4  0001-Use-AVERROR_INVALIDDATA-rather-than-1-for-nutdec-err.patch
> > From 72e227767d4b7e5418f8ca8e0b421be6aaeb0e75 Mon Sep 17 00:00:00 2001
> > From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > Date: Tue, 11 Jan 2011 23:51:01 +0100
> > Subject: [PATCH] Use AVERROR_INVALIDDATA rather than -1 for nutdec error codes.
> > 
> > ---
> >  libavformat/nutdec.c |   28 ++++++++++++++--------------
> >  1 files changed, 14 insertions(+), 14 deletions(-)
> 
> lgtm if tested

Applied.
-- 
FFmpeg = Fantastic Faithful Magic Pure Egregious Governor



More information about the ffmpeg-devel mailing list