[ovs-dev] [sparse 13/18] util: Suppress build assertions when building with sparse.

Ethan Jackson ethan at nicira.com
Fri May 13 01:00:01 UTC 2011


Looks Good.

Ethan

On Fri, May 6, 2011 at 13:16, Ben Pfaff <blp at nicira.com> wrote:
> sparse simply doesn't like our build assertions on packed structures.
> It seems that its ideas about struct packing are different from GCC's:
>
> ../lib/cfm.h:50:1: error: invalid bitfield width, -1.
> ../lib/packets.h:206:1: error: invalid bitfield width, -1.
> ../lib/packets.h:213:1: error: invalid bitfield width, -1.
> ../lib/packets.h:367:1: error: invalid bitfield width, -1.
>
> sparse isn't generating code so we don't really care how it lays out
> structures.  We might as well just skip the assertions, as done here.
> ---
>  lib/util.h |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/lib/util.h b/lib/util.h
> index 9c2352f..0c80a6f 100644
> --- a/lib/util.h
> +++ b/lib/util.h
> @@ -33,7 +33,10 @@
>  #endif
>  #endif
>
> -#ifndef __cplusplus
> +#ifdef __CHECKER__
> +#define BUILD_ASSERT(EXPR) ((void) 0)
> +#define BUILD_ASSERT_DECL(EXPR) extern int (*build_assert(void))[1]
> +#elif !defined(__cplusplus)
>  /* Build-time assertion building block. */
>  #define BUILD_ASSERT__(EXPR) \
>         sizeof(struct { unsigned int build_assert_failed : (EXPR) ? 1 : -1; })
> --
> 1.7.4.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list