[Freeipa-devel] [PATCH 0026] Enable building in C99 mode

Simo Sorce simo at redhat.com
Tue Dec 17 13:58:26 UTC 2013


On Tue, 2013-12-17 at 08:47 -0500, Nathaniel McCallum wrote:
> On Tue, 2013-12-17 at 10:29 +0100, Petr Spacek wrote:
> > On 17.12.2013 10:12, Jakub Hrozek wrote:
> > > On Tue, Dec 17, 2013 at 08:19:09AM +0100, Jan Cholasta wrote:
> > >> Hi,
> > >>
> > >> On 16.12.2013 22:12, Nathaniel McCallum wrote:
> > >>> Patch attached.
> > >>
> > >> Care to elaborate? There's no ticket or explanation why this is
> > >> beneficial or necessary.
> > >
> > > We had a short chat with Nathaniel yesterday on IRC about which C standards
> > > we, as a project, allow. I think this patch is a result of that discussion.
> > >
> > > SSSD has had -std=gnu99 in the default CFLAGS for more than a year now.
> > >
> > > I think we can safely support C99 and its features now, it's almost 2014
> > > and all major compilers support the features we care about. But I think
> > > this change should go hand-in-hand with amending
> > > http://www.freeipa.org/page/Coding_Style
> > >
> > > For instance, would variable-length arrays considered OK? (I would vote
> > > yes),
> > 
> > Please no. You can't catch the error if the memory allocation fails for 
> > whatever reason and the process will killed by OS.
> > 
> > (There is a question if you want to handle memory allocation failures at all, 
> > of course.)
> 
> I think this can be reasonably be used with appropriately documented
> caution.

+1

> >  > would intermingled code and declarations be considered OK (I
> > > personally dislike these), etc?
> > 
> > Neither do I :-)
> 
> +1, with the exception of declarations at the beginning of the block,
> which I find useful (I know this isn't C99).

+1, although in general declarations in blocks should really be sparse
and only for very local very temporary variables, and generally *not*
for pointers that hold the only reference to allocated memory (as then a
goto error statement will not be possible as the variable is out of
context and can't be freed in the exception handling part of the code
after the label).

> Features that I don't want to live without:
> 1. Standard struct initializers
> 2. Compound literals
> 3. For-loop declarations
> 4. Standard bool type

I am pretty much +1 on C99 as the minimum common denominator for our
code.

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York




More information about the Freeipa-devel mailing list