[Spice-devel] [client 2/2] streaming: Use the frame dimensions reported by the video decoder

Francois Gouget fgouget at codeweavers.com
Wed May 25 23:26:00 UTC 2016


On Wed, 25 May 2016, Pavel Grunt wrote:
[...]
> > +    do {
> it is preferred to declare variables at the beginning of the block.

That does not seem to be mentionned in the Spice coding style and 
conventions:
http://www.spice-space.org/static/docs/spice_style.pdf

There's also quite a few cases already (not even all by me!), though 
I'll admit that probably not the prevalent style).

Is the goal to keep compatibility with C89 compilers? (that boat has 
sailed a long time ago)

I personally quite like that this makes it possible to keep the variable 
declarations close to where they are used so one can easily see both 
without having to scroll all the way up to the start of the function. It 
also makes it possible to further restrict the scope of the variables. 
Overall I think it makes the code more readable.


> imo a 'goto' would be more readable than do {} while(FALSE)

The problem with a goto is that then the compiler complains about some 
variables not being initialized due to the goto. That said moving the 
declarations to the start of the function makes the warnings go away. So 
it would work [1].

Another option is lots of nested ifs but that's frowned upon by the 
Spice coding standard.



[1] It also means the compiler is really dumb because separating 
    the declaration from the initialization should make no difference.

    In fact we already knew the compiler is a bit dumb since the 
    variables are not used after the goto at all so it makes no sense to 
    complain that the goto will leave them uninitialized.



-- 
Francois Gouget <fgouget at codeweavers.com>


More information about the Spice-devel mailing list