From: Jarno Rajahalme Date: Wed, 28 May 2014 23:56:29 +0000 (-0700) Subject: CodingStyle: Allow C99 mixing of declarations and code. X-Git-Tag: v2.4.0~2075 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=7c96151e33dcb8e547d2bd19de4a1ec62b2b36a0 CodingStyle: Allow C99 mixing of declarations and code. As even the MSVC 2013 now supports the C99 mixing of declarations and code, we can now allow them in OVS code. Signed-off-by: Jarno Rajahalme Acked-by: Ben Pfaff --- diff --git a/CodingStyle b/CodingStyle index bae8cd65c..0ba036697 100644 --- a/CodingStyle +++ b/CodingStyle @@ -515,7 +515,7 @@ global variables. C DIALECT - Some C99 features are OK because they are widely implemented: + Most C99 features are OK because they are widely implemented: * Flexible array members (e.g. struct { int foo[]; }). @@ -533,16 +533,15 @@ C DIALECT * Designated initializers (e.g. "struct foo foo = {.a = 1};" and "int a[] = {[2] = 5};"). - Don't use other C99 features that are not widely implemented in -older compilers: + * Mixing of declarations and code within a block. Please use this + judiciously; keep declarations nicely grouped together in the + beginning of a block if possible. - * Don't mix declarations and code within a block. - - * Don't use declarations in iteration statements (e.g. don't write + * Use of declarations in iteration statements (e.g. "for (int i = 0; i < 10; i++)"). - * Don't put a trailing comma in an enum declaration (e.g. don't - write "enum { x = 1, };"). + * Use of a trailing comma in an enum declaration (e.g. + "enum { x = 1, };"). As a matter of style, avoid // comments. diff --git a/acinclude.m4 b/acinclude.m4 index 5ed02d21a..bd71a82a7 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -403,7 +403,7 @@ dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([_OVS_CHECK_CC_OPTION], [dnl - m4_define([ovs_cv_name], [ovs_cv_[]m4_translit([$1], [-], [_])])dnl + m4_define([ovs_cv_name], [ovs_cv_[]m4_translit([$1], [-=], [__])])dnl AC_CACHE_CHECK([whether $CC accepts $1], [ovs_cv_name], [ovs_save_CFLAGS="$CFLAGS" dnl Include -Werror in the compiler options, because without -Werror diff --git a/configure.ac b/configure.ac index 3379ff657..4bf69e868 100644 --- a/configure.ac +++ b/configure.ac @@ -100,7 +100,6 @@ OVS_ENABLE_OPTION([-Wall]) OVS_ENABLE_OPTION([-Wextra]) OVS_ENABLE_OPTION([-Wno-sign-compare]) OVS_ENABLE_OPTION([-Wpointer-arith]) -OVS_ENABLE_OPTION([-Wdeclaration-after-statement]) OVS_ENABLE_OPTION([-Wformat-security]) OVS_ENABLE_OPTION([-Wno-format-zero-length]) OVS_ENABLE_OPTION([-Wswitch-enum])