[MPlayer-dev-eng] [PATCH] Use BUFLENGTH for buf defined in draw_image

Clément Bœsch ubitux at gmail.com
Mon Dec 13 14:20:21 CET 2010


On Sun, Dec 12, 2010 at 03:26:38PM -0200, Marco Aurélio Graciotto Silva wrote:
> In libvo/vo_png.c, the variable 'buf', used to create the output
> PNG filename, has a constant size of 100. However, vo_png.c
> already defines and uses a constant, BUFLENGTH, for a similar
> purpose at config(). So, I changed draw_image() to use
> BUFLENGTH instead of 100 as its size.
> 
> 
> Regards,
> 
> Marco

> Index: libvo/vo_png.c
> ===================================================================
> --- libvo/vo_png.c	(revision 32708)
> +++ libvo/vo_png.c	(working copy)
> @@ -129,13 +129,13 @@
>      AVFrame pic;
>      int buffersize;
>      int res;
> -    char buf[100];
> +    char buf[BUFLENGTH];
>      FILE *outfile;
>  
>      // if -dr or -slices then do nothing:
>      if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE;
>  
> -    snprintf (buf, 100, "%s/%08d.png", png_outdir, ++framenum);
> +    snprintf(buf, BUFLENGTH, "%s/%08d.png", png_outdir, ++framenum);
>      outfile = fopen(buf, "wb");
>      if (!outfile) {
>          mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno));

This looks ok to me, but you should use sizeof(buf) instead of reusing the
BUFLENGTH macro in snprintf.

I'm also wondering if there is no other similar macro defined elsewhere
that could be use… But well, this is not that important.

-- 
Clément B.
Not sent from a jesusPhone.


More information about the MPlayer-dev-eng mailing list