[FFmpeg-devel] [PATCH] Fix flush_pkt warning in ffplay.c

Stefano Sabatini stefano.sabatini-lala
Sun Dec 28 18:04:21 CET 2008


On date Thursday 2008-12-04 11:55:38 +0100, Michael Niedermayer encoded:
> On Thu, Dec 04, 2008 at 09:12:08AM +0100, Stefano Sabatini wrote:
> > On date Wednesday 2008-12-03 16:25:00 -0800, Baptiste Coudurier encoded:
> > > Hi,
> > > 
> > > Stefano Sabatini wrote:
> > > > Hi,
> > > > 
> > > > this fixes the warning:
> > > > ffplay.c: In function ?main?:
> > > > ffplay.c:2875: warning: assignment discards qualifiers from pointer target type
> > > > 
> > > > Regards.
> > > > 
> > > > 
> > > > ------------------------------------------------------------------------
> > > > 
> > > > Index: ffplay.c
> > > > ===================================================================
> > > > --- ffplay.c	(revision 15995)
> > > > +++ ffplay.c	(working copy)
> > > > @@ -2583,7 +2583,7 @@
> > > >      SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
> > > >  
> > > >      av_init_packet(&flush_pkt);
> > > > -    flush_pkt.data= "FLUSH";
> > > > +    flush_pkt.data= av_strdup("FLUSH");
> > > 
> > > Set destruct_packet then to free 'data'.
> > 
> > Yes, regards.
> 
> patch rejected, flush_pkt.data MUST NOT be freed this would
> break the code. The packet is used many times (and could be "freed") it is
> allocated only once in main()
> the original code is correct, a solution to the warning should not change
> ffplay.o, especially it should not add extra code into the object file as
> there is no need for that.

flush_pkt.data is never freed in the code with or without the non-const
data (or the program would crash), and I don't think that an
av_strdup() call will make things so worse.

But I see that having the program crash if flush_pkt.data is attempted
to be freed is a good way to make the programmer aware that he
introduced some bug.

Unfortunately also there is no way to disable specifics warnings
(e.g. with pragma directives), and to postprocess the build output to
manually remove that warning is fragile and overkill, so that means
that I'll try to withstand that fastidious warning...

Regards.
-- 
FFmpeg = Fundamental & Freak Minimalistic Puristic Elected Guru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-flush-warning.patch
Type: text/x-diff
Size: 342 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081228/d24a6360/attachment.patch>



More information about the ffmpeg-devel mailing list