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

Stefano Sabatini stefano.sabatini-lala
Tue Jan 11 23:56:15 CET 2011


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



More information about the ffmpeg-devel mailing list