Re: [client 2/2] streaming: Use the frame dimensions reported by the video decoder

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Francois,

On Thu, 2016-05-26 at 01:26 +0200, Francois Gouget wrote:
> 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

I am sorry about that, the doc is outdated, recently we are trying to update it:
https://cgit.freedesktop.org/spice/spice/tree/docs/spice_style.txt
http://www.spice-space.org/spice-project-coding-style-and-coding-conventions.htm
l

> 
> There's also quite a few cases already (not even all by me!), though 
> I'll admit that probably not the prevalent style).
sometimes it was not spotted during reviews (my bad), but I don't think there
are many cases.

> 
> Is the goal to keep compatibility with C89 compilers? (that boat has 
> sailed a long time ago)
same for C99... It is more about separating declarations from the code,
personally I find it more readable (it is possible that I am just used to it).
Maybe there are more reasons...

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

goto is used a lot in spice-gtk, but "do {} while(FALSE)" is only used in macro
definitions.

Pavel
> 
> 
> 
> [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.
> 
> 
> 
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]