[ovs-dev] [PATCH 1/5] CodingStyle: Allow C99 mixing of declarations and code.

Ben Pfaff blp at nicira.com
Wed May 28 22:31:52 UTC 2014


On Wed, May 28, 2014 at 03:31:03PM -0700, Jarno Rajahalme wrote:
> 
> On May 23, 2014, at 10:04 AM, Ben Pfaff <blp at nicira.com> wrote:
> 
> > On Thu, May 22, 2014 at 05:37:38PM -0700, Jarno Rajahalme wrote:
> >> As even the MSVC 2013 now supports the C99 mixing of declarations and
> >> code, we can now allow them in OVS code.
> >> 
> >> GCC (at least some versions of it) require the -std=c99 option to not
> >> issue warnings, and since we rely in GCC extensions when compiling
> >> with GCC, the option -std=gnu99 is now added to the CFLAGS by
> >> configure, if the compiler accepts it.
> >> 
> >> Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
> > 
> > Are you sure that this line in configure.ac isn't the root of the
> > problem?
> > 
> > OVS_ENABLE_OPTION([-Wdeclaration-after-statement])
> 
> I did not notice this, sorry. It turned out to be the problem, so there is no need to add the -std option.
> 
> I left in the change in transliterating the ?=? as well as ?-? to ?_? so that if we ever need to add options with ?=? in them, there should be no problems in doing so.
> 
> > 
> > I'm still really nervous about this one (I think it often uglifies code)
> > but let's give it a shot:
> > 
> 
> If it turns out to be too ugly we can always take this one back.
> 
> >> -    * Don't mix declarations and code within a block.
> >> +    * Mixing of declarations and code within a block.
> > 
> >> +  Don't use other C99 features that are not widely implemented in
> >> +older compilers:
> >> +
> > 
> > We have enough of these in the source that I think they're not a problem
> > in practice anymore, so let's delete this one too:
> > 
> >>     * Don't put a trailing comma in an enum declaration (e.g. don't
> >>       write "enum { x = 1, };").
> > 
> 
> Ok, I?ll change this too. How about this incremental:

That's fine, thank you.



More information about the dev mailing list