[FFmpeg-devel] [PATCH] vhook/{fish, ppm}.c: Fix compilation warnings

Aurelien Jacobs aurel
Sat Feb 14 15:27:41 CET 2009


Patrik Kullman wrote:

> Even though VHOOK is deprecated, I thought that making it compile as
> cleanly as possible would be a good thing before the release.
> 
> But also since it's deprecated, I thought I'd submit everything in one
> patch.
> 
> These are the warnings I try to prevent:
> 
> vhook/fish.c: In function ?Configure?:
> vhook/fish.c:130: warning: assignment discards qualifiers from pointer target type
> 
> Patch: Use av_strlcpy
> 
> [...]
> 
> Index: vhook/fish.c
> ===================================================================
> --- vhook/fish.c	(revision 17221)
> +++ vhook/fish.c	(working copy)
> [...]
> @@ -127,7 +128,7 @@
>  
>      optind = 1;
>  
> -    ci->dir = "/tmp";
> +    av_strlcpy(ci->dir, "/tmp", 4);
>      ci->threshold = 100;
>      ci->file_limit = 100;
>      ci->min_interval = 1000000;
> @@ -368,7 +369,8 @@

This is wrong. ci->dir is never initialized. Maybe you should use
av_strdup() instead. (and add the proper av_free() to avoid
memory leak).

> Index: vhook/ppm.c
> ===================================================================
> --- vhook/ppm.c	(revision 17221)
> +++ vhook/ppm.c	(working copy)
> [...]
> @@ -232,8 +237,8 @@
>      AVPicture picture1;
>      AVPicture picture2;
>      AVPicture *pict = picture;
> -    int out_width;
> -    int out_height;
> +    int av_uninit(out_width);
> +    int av_uninit(out_height);

This looks wrong. The warning is not a false positive.
If the call to rwpipe_read_ppm_header() fails, those variable
could really be used uninitialized.

Aurel




More information about the ffmpeg-devel mailing list