[FFmpeg-devel] [PATCH] use strings for error return values in seek_test

Michael Niedermayer michaelni
Fri Oct 2 20:58:07 CEST 2009


On Fri, Oct 02, 2009 at 02:38:06PM +0200, Reimar D?ffinger wrote:
> On Fri, Oct 02, 2009 at 12:23:34PM +0200, Michael Niedermayer wrote:
> > > Index: tests/seek_test.c
> > > ===================================================================
> > > --- tests/seek_test.c	(revision 20105)
> > > +++ tests/seek_test.c	(working copy)
> > > @@ -30,6 +30,20 @@
> > >  #undef printf
> > >  #undef fprintf
> > >  
> > > +static char buffer[20];
> > > +
> > > +static char *ret_str(int v)
> > > +{
> > > +    switch (v) {
> > > +    case AVERROR_EOF:     return "-EOF";
> > > +    case AVERROR(EIO):    return "-EIO";
> > > +    case AVERROR(ENOMEM): return "-ENOMEM";
> > > +    case AVERROR(EINVAL): return "-EINVAL";
> > > +    }
> > > +    snprintf(buffer, sizeof(buffer), "%2d", v);
> > > +    return buffer;
> > 
> > a default: would look more consistent
> 
> Sure, done.
> 
> > >  int main(int argc, char **argv)
> > >  {
> > >      const char *filename;
> > > @@ -78,7 +92,7 @@
> > >          memset(&pkt, 0, sizeof(pkt));
> > >          if(ret>=0){
> > >              ret= av_read_frame(ic, &pkt);
> > > -            printf("ret:%2d", ret);
> > > +            printf("ret:%s", ret_str(ret));
> > 
> > something to make this constant size so that vertical alignment is maintained
> > would be nice
> 
> Note that it is still aligned for 0 and -1, and most of the error cases (IMO all
> except those that are broken) only print this ret: part (and they were aligned before).
> Apart from that it should be only a matter of changing %s to e.g. %-10s, but that would

> 1) make the already long lines even longer

theres alot that can be droped to make them shorter (the -E comes to mind)


> 2) it will change _all_ the lines in the regressions file
> I don't mind changing it, the effort is minimal but due to 2) it should be at least
> in a separate patch.

of course


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091002/a501efe4/attachment.pgp>



More information about the ffmpeg-devel mailing list