From: Ben Pfaff Date: Fri, 6 May 2011 18:38:19 +0000 (-0700) Subject: Suppress sparse warnings for global variables initialized in headers. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4070db7e5ae7727876d6cc318fba10033dc2c85;p=openvswitch Suppress sparse warnings for global variables initialized in headers. 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? --- diff --git a/lib/coverage.h b/lib/coverage.h index d816fb61..b7db6c47 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 4244fca9..9d6ea97f 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 12844c6f..3f40c297 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 */ \