Thanks for the insight.

On Tue, Aug 20, 2013 at 3:39 PM, Ben Pfaff <[email protected]> wrote:

> To expand on that, usually one defines a non-static variable, in a .c
> file, only when an "extern" declaration of the same variable is
> already visible from #including an .h file.  A definition without a
> previous declaration usually means that the .h file was forgotten.
>
> On Tue, Aug 20, 2013 at 02:48:57PM -0700, Alex Wang wrote:
> > I found the answer from this thread:
> > http://openvswitch.org/pipermail/dev/2011-May/008608.html
> >
> >
> >
> > On Tue, Aug 20, 2013 at 2:02 PM, Alex Wang <[email protected]> wrote:
> >
> > > May I ask, what rule is this?
> > >
> > > Should we always declare global variable before defining it? or just
> when
> > > it is enclosed by macros?
> > >
> > > Also, when the "!USE_LINKER_SECTIONS", we should modify the coverage.c
> the
> > > same way. I'll send out a patch,
> > >
> > >
> > > On Tue, Aug 20, 2013 at 1:44 PM, Ben Pfaff <[email protected]> wrote:
> > >
> > >> On Mon, Aug 19, 2013 at 12:32:06PM -0700, Alex Wang wrote:
> > >> > Just noticed, when compiling with sparse, it issues the warnings
> like:
> > >> >
> > >> > """
> > >> > lib/netdev-linux.c:76:1: warning: symbol
> 'counter_netdev_set_policing'
> > >> was
> > >> > not declared. Should it be static?
> > >> > lib/netdev-linux.c:77:1: warning: symbol
> 'counter_netdev_arp_lookup' was
> > >> > not declared. Should it be static?
> > >> > lib/netdev-linux.c:78:1: warning: symbol
> 'counter_netdev_get_ifindex'
> > >> was
> > >> > not declared. Should it be static?
> > >> > """
> > >>
> > >> Ouch, thanks, I folded in this incremental to fix that:
> > >>
> > >> diff --git a/lib/coverage.h b/lib/coverage.h
> > >> index 73b027a..3d1a115 100644
> > >> --- a/lib/coverage.h
> > >> +++ b/lib/coverage.h
> > >> @@ -54,6 +54,7 @@ struct coverage_counter {
> > >>          {
>     \
> > >>              *counter_##COUNTER##_get() += n;
>    \
> > >>          }
>     \
> > >> +        extern struct coverage_counter counter_##COUNTER;
>     \
> > >>          struct coverage_counter counter_##COUNTER
>     \
> > >>              = { #COUNTER, COUNTER##_count, 0 };
>     \
> > >>          extern struct coverage_counter *counter_ptr_##COUNTER;
>    \
> > >>
> > >
> > >
>
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to