[FFmpeg-devel] [PATCH] Remove final semicolons from get_bits macros

Måns Rullgård mans
Sun Feb 21 04:05:12 CET 2010


Michael Niedermayer <michaelni at gmx.at> writes:

> On Sun, Feb 21, 2010 at 02:43:46AM +0000, M?ns Rullg?rd wrote:
>> Michael Niedermayer <michaelni at gmx.at> writes:
>> 
>> > On Sun, Feb 21, 2010 at 01:19:16AM +0000, M?ns Rullg?rd wrote:
>> >> Mans Rullgard <mans at mansr.com> writes:
>> >> 
>> >> > Some of the macros in get_bits.h include a final semicolon.  This
>> >> > removes them and adds semicolons as necessary where these macros
>> >> > are invoked.
>> >> >
>> >> > Tested with all three readers.
>> >> > ---
>> >> >  libavcodec/get_bits.h |  118 ++++++++++++++++++++++++------------------------
>> >> >  libavcodec/mjpegdec.c |   24 +++++-----
>> >> >  2 files changed, 71 insertions(+), 71 deletions(-)
>> >> 
>> >> ping
>> >
>> > I prefer them with the semicolons as they are
>> > They are blocks of code not single statements
>> > This of course is arguably a bikeshed issue but to me
>> >
>> > if(X)
>> >     MAKRO()
>> >
>> > reminds me that i forgot something
>> > while
>> >
>> > if(X)
>> >     MAKRO();
>> >
>> > looks like a function call
>> > and then someone will argue that we need
>> > do{
>> > }while(0)
>> 
>> Which we should, dammit.
>
> i dont like red tape
> it just makes markos behave like something that they are not

It makes them both be and look like a single statement with respect to
flow control.  With or without builtin semicolons, naked
multi-statement macros are dangerous if someone decides to write

    if (cond)
        macro();

Debugging such mistakes makes me want to kill whoever wrote the
macro.  You wrote some of them...

>> I've tripped over those bizarre semicolons of yours too many times.
>
> and at least i would be tripping over the alternative too many times

Then tell me how the hell you manage to remember which
function-call-like things should have a semicolon and which ones
shouldn't.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list