[MPlayer-dev-eng] [PATCH] Yet another batch of warning fixes :->
Anders Johansson
ajh at watri.uwa.edu.au
Wed Dec 11 02:13:57 CET 2002
Hi,
> On Tuesday, 10 December 2002, Anders Johansson wrote:
> > Hi,
> >
> > > Hi,
> > >
> > > > > > #define ADDQUE(xi,xq,in)\
> > > > > > xq[xi]=xq[xi+L]=(*in);\
> > > > > > - xi=(--xi)&(L-1);
> > > > > > + xi=(xi-1)&(L-1);\
> > > > > > + xi--;
> > > > >
> > > > > why?
> > > >
> > > > He's correct that something's wrong here. Read the comp.lang.c faq.
> > > > The result of an expression similar to x=--x; is undefined. I have no
> > > ah. you're right
> > > but then, that extra xi--; is unneeded and wrong
> > >
> > > so, the right fix would be:
> > > - xi=(--xi)&(L-1);
> > > + xi=(xi-1)&(L-1);
> > >
> > > IMHO, Anders should confirm.
> >
> > It is the index for a circular buffer, the sulution Arpi suggests
> > should work fine, but I haven't got time to test it right now.
>
> Then why was xi decreased if it's not needed? My code does exactly the same
> thing as the original one. I won't insist on my solution, though. My
> intention was to tell you something was wrong there, and I've succeeded. :->
I am sorry but your code:
> > > > > > + xi=(xi-1)&(L-1);\
> > > > > > + xi--;
does not do the same thing as:
> > > + xi=(xi-1)&(L-1);
You have to observe that this is a macro, not a function, your code
would result in irregular indexing of the circular buffer.
//Anders
More information about the MPlayer-dev-eng
mailing list