2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +00:00

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?
This commit is contained in:
Ben Pfaff
2011-05-06 11:38:19 -07:00
parent 2932bd0512
commit f4070db7e5
3 changed files with 8 additions and 2 deletions

View File

@@ -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 */