[ovs-dev] [sparse 12/18] Suppress sparse warnings for global variables initialized in headers.
Ethan Jackson
ethan at nicira.com
Fri May 13 00:57:49 UTC 2011
Looks Good.
Ethan
On Fri, May 6, 2011 at 13:16, Ben Pfaff <blp at nicira.com> wrote:
> sparse warns if a non-static variable with external linkage has an
> initializer at first declaration, because it suspects that it should be
> static instead. Generally it's correct, but not in these cases, so add
> a redundant declaration to suppress the warning.
>
> The suppress warnings look like:
> ../ofproto/connmgr.c:40:1: warning: symbol 'VLM_connmgr' was not declared. Should it be static?
> ../ofproto/collectors.c:31:1: warning: symbol 'vlog_module_ptr_collectors' was not declared. Should it be static?
> ../ofproto/connmgr.c:43:1: warning: symbol 'counter_ofconn_stuck' was not declared. Should it be static?
> ---
> lib/coverage.h | 4 +++-
> lib/stress.h | 4 +++-
> lib/vlog.h | 2 ++
> 3 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/lib/coverage.h b/lib/coverage.h
> index d816fb6..b7db6c4 100644
> --- a/lib/coverage.h
> +++ b/lib/coverage.h
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2009, 2010 Nicira Networks.
> + * Copyright (c) 2009, 2010, 2011 Nicira Networks.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -41,6 +41,7 @@ struct coverage_counter {
> #if USE_LINKER_SECTIONS
> #define COVERAGE_DEFINE(COUNTER) \
> COVERAGE_DEFINE__(COUNTER); \
> + extern struct coverage_counter *counter_ptr_##COUNTER; \
> struct coverage_counter *counter_ptr_##COUNTER \
> __attribute__((section("coverage"))) = &counter_##COUNTER
> #else
> @@ -60,6 +61,7 @@ void coverage_clear(void);
>
> /* Implementation detail. */
> #define COVERAGE_DEFINE__(COUNTER) \
> + extern struct coverage_counter counter_##COUNTER; \
> struct coverage_counter counter_##COUNTER = { #COUNTER, 0, 0 }
>
> #endif /* coverage.h */
> diff --git a/lib/stress.h b/lib/stress.h
> index 4244fca..9d6ea97 100644
> --- a/lib/stress.h
> +++ b/lib/stress.h
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2010 Nicira Networks.
> + * Copyright (c) 2010, 2011 Nicira Networks.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -60,6 +60,7 @@ struct stress_option {
> #if USE_LINKER_SECTIONS
> #define STRESS_OPTION(NAME, DESCRIPTION, RECOMMENDED, MIN, MAX, DEFAULT) \
> STRESS_OPTION__(NAME, DESCRIPTION, RECOMMENDED, MIN, MAX, DEFAULT); \
> + extern struct stress_option *stress_option_ptr_##NAME; \
> struct stress_option *stress_option_ptr_##NAME \
> __attribute__((section("stress_options"))) = &stress_##NAME
> #else
> @@ -76,6 +77,7 @@ void stress_init_command(void);
> /* Implementation details. */
>
> #define STRESS_OPTION__(NAME, DESCRIPTION, RECOMMENDED, MIN, MAX, DEFAULT) \
> + extern struct stress_option stress_##NAME; \
> struct stress_option stress_##NAME = \
> { #NAME, DESCRIPTION, RECOMMENDED, MIN, MAX, DEFAULT, \
> DEFAULT ? DEFAULT : 0, /* period */ \
> diff --git a/lib/vlog.h b/lib/vlog.h
> index 12844c6..3f40c29 100644
> --- a/lib/vlog.h
> +++ b/lib/vlog.h
> @@ -92,6 +92,7 @@ struct vlog_module {
> #if USE_LINKER_SECTIONS
> #define VLOG_DEFINE_MODULE(MODULE) \
> VLOG_DEFINE_MODULE__(MODULE) \
> + extern struct vlog_module *vlog_module_ptr_##MODULE; \
> struct vlog_module *vlog_module_ptr_##MODULE \
> __attribute__((section("vlog_modules"))) = &VLM_##MODULE
> #else
> @@ -258,6 +259,7 @@ void vlog_usage(void);
> } while (0)
>
> #define VLOG_DEFINE_MODULE__(MODULE) \
> + extern struct vlog_module VLM_##MODULE; \
> struct vlog_module VLM_##MODULE = \
> { \
> #MODULE, /* name */ \
> --
> 1.7.4.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
More information about the dev
mailing list