[Spice-devel] Different styles

Jonathon Jongsma jjongsma at redhat.com
Wed May 25 14:45:27 UTC 2016


On Wed, 2016-05-25 at 08:31 -0400, Frediano Ziglio wrote:
> Hi,
>   I was reading the style document and I found some different styles in the
> code
> 
> The structures for GObject differs from the rest of the code, they are
> 
> struct DispatcherClass
> {
>     GObjectClass parent_class;
> };
> 
> instead of
> 
> struct DispatcherClass {
>     GObjectClass parent_class;
> };
> 
> (all other structure follow this schema)

Probably just an error accidentally introduced by me as the first style is more
my personal coding style.

> 
> 
> There is a chapter "Vertical indentation" which state that there is no
> vertical indentation quoting even some example of functions however
> there are some code, like
> 
> void red_qxl_on_ic_change(QXLInstance *qxl, SpiceImageCompression ic);
> void red_qxl_on_sv_change(QXLInstance *qxl, int sv);
> void red_qxl_set_mouse_mode(QXLInstance *qxl, uint32_t mode);
> void red_qxl_attach_worker(QXLInstance *qxl);
> 
> that follow these specification while others
> 
> void                       display_channel_draw                     
>  (DisplayChannel *display,
>                                                                       const
> SpiceRect *area,
>                                                                       int
> surface_id);
> void                       display_channel_draw_until               
>  (DisplayChannel *display,
>                                                                       const
> SpiceRect *area,
>                                                                       int
> surface_id,
>                                                                       Drawable
> *last);
> void                       display_channel_update                   
>  (DisplayChannel *display,
>                                                                       uint32_t
> surface_id,
>                                                                       const
> QXLRect *area,
> 
> that clearly use vertical indentation.
> 
> I personally find that vertical indentation tend to cause long lines and
> it's hard to maintain when new declarations are added (like requiring
> new indentation) but the main argument is that I'd like to follow same
> rules or define exceptions with rules (like structure declarations for
> GObject have bracket on first column).


I also find that the second style is harder to maintain and harder to read. I
haven't really done any re-formatting of this style function declarations, but I
have generally avoided adding new functions in this style. Although that means
that I may have introduced a mixture of styles in a single header...

Jonathon


More information about the Spice-devel mailing list