[Spice-devel] [PATCH 1/2] unify header include order

Frediano Ziglio fziglio at redhat.com
Wed May 11 16:25:00 UTC 2016


> 
> On Tue, May 10, 2016 at 02:23:04PM +0100, Frediano Ziglio wrote:
> > Use this style for include headers inside headers:
> > 
> >   #include <system_headers.h>
> >   #include <no_spice_no_system_libraries.h>
> >   #include <spice_protocol.h>
> >   #include <spice_common.h>
> > 
> >   #include "spice_server.h"
> 
> I would add that to this coding style document if it's not already
> there. I tend to prefer when the headers are alphabetically ordered
> within a given section (probably not worth changing throughout the
> codebase now, but could be nice to keep an eye on that when adding new
> #includes)
> 

I think the alphabetical order is a bit too strict.
Also for experience some - even system - headers needs to
be included before some others just to avoid bugs (first I
remember is windows.h and winsock2.h but even HP-UX and
others systems, I remember one nasty problem with a stdarg.h).

> 
> > diff --git a/server/red-channel.h b/server/red-channel.h
> > index bc225c6..03e6407 100644
> > --- a/server/red-channel.h
> > +++ b/server/red-channel.h
> > @@ -24,7 +24,6 @@
> >  
> >  #include <pthread.h>
> >  #include <limits.h>
> > -
> >  #include <common/ring.h>
> >  #include <common/marshaller.h>
> >  
> > diff --git a/server/red-common.h b/server/red-common.h
> > index 3a63f04..b92bbee 100644
> > --- a/server/red-common.h
> > +++ b/server/red-common.h
> > @@ -18,14 +18,14 @@
> >  #ifndef _H_RED_COMMON
> >  #define _H_RED_COMMON
> >  
> > -#include <glib.h>
> > -
> >  #include <errno.h>
> >  #include <stdbool.h>
> >  #include <stdint.h>
> >  #include <string.h>
> >  #include <unistd.h>
> >  
> > +#include <glib.h>
> > +
> >  #include <spice/macros.h>
> >  #include <common/log.h>
> >  #include <common/lz_common.h>
> 
> Nit, but this hunk and the previous one seems a bit inconsistent with
> respect to the blank line. Do you want to group all <> #includes, or to
> separate each different sections?
> 

Yes, you are right, I'll remove empty lines in this last hunk, is the only
exception.

> Acked-by: Christophe Fergeau <cfergeau at redhat.com>
> 
> Christophe
> 

I think the ack still remains even without the empty lines...
we are not using Python!

Frediano


More information about the Spice-devel mailing list