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

Patrik Kullman patrik
Mon Feb 16 10:32:59 CET 2009


On Sat, 2009-02-14 at 15:27 +0100, Aurelien Jacobs wrote:
> 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).

Ok, using av_strdup().

ci is free'd in Release(), also, ci->dir is already set through
av_strdup() if the command line argument is passed, so this shouldn't
make any difference.

> > 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.

Yeah sorry about that.

The av_uninit()-hunk is already in SVN though, this patch removes it
again.

Moving the last part of the function to within the same if-statement to
prevent uninitialization of the out_* ints.

> Aurel
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-vhook-compilation_warnings.patch
Type: text/x-patch
Size: 3920 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090216/bfbc89e3/attachment.bin>



More information about the ffmpeg-devel mailing list