[FFmpeg-devel] [PATCH] use strings for error return values in seek_test
Reimar Döffinger
Reimar.Doeffinger
Fri Oct 2 14:38:06 CEST 2009
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
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.
What do you/others think?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: seek_errstr.diff
Type: text/x-diff
Size: 1677 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091002/b692d1cb/attachment.diff>
More information about the ffmpeg-devel
mailing list