public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] netfilter: save the hash of the tuple in the original direction for latter use
       [not found]         ` <AANLkTinA3-KMPKJa-66QCMUpbDFwey2mjE=VN=9=zg=6@mail.gmail.com>
@ 2010-08-20 13:43           ` Mathieu Desnoyers
  0 siblings, 0 replies; only message in thread
From: Mathieu Desnoyers @ 2010-08-20 13:43 UTC (permalink / raw)
  To: Changli Gao
  Cc: Eric Dumazet, Patrick McHardy, David S. Miller, netfilter-devel,
	netdev, akpm, linux-kernel

[ executive summary: trying to explain why static variable declarations
  within the body of functions is bad in kernel code. ]

* Changli Gao (xiaosuo@gmail.com) wrote:
> On Fri, Aug 20, 2010 at 12:11 AM, Mathieu Desnoyers
> <mathieu.desnoyers@polymtl.ca> wrote:
> >
> > Ah, I see. But I think the static variable should stay declared outside
> > of the function scope, with a nice comment explaining why it's not
> > initialized at init-time.
> >
> > Hiding global state in function code is usually frowned upon.
> >
> 
> I don't agree with you. We'd better not expose the variable which
> isn't expected to be used by others. If not, maybe someone will misuse
> it.

We are talking about a static variable usable only within a single file,
where is the problem ? A nice comment can have this effect.

> The user should only reply on the interface, but not the internal
> implementation.

I'm talking about good practice to help code review. This is way more
important than the potential "encapsulation" benefit of hiding global
state (a static variable) within the body of a function.

I remember that Andrew Morton has strong opinions about this, and I
remember being in complete agreement with him on the topic.

Thanks,

Mathieu

> 
> Thanks.
> 
> -- 
> Regards,
> Changli Gao(xiaosuo@gmail.com)

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-20 13:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1282228389-3029-1-git-send-email-xiaosuo@gmail.com>
     [not found] ` <20100819152149.GA19744@Krystal>
     [not found]   ` <AANLkTim5wn0Y-+081gvm7FkWx3NioRvtRMWy2uF4nji2@mail.gmail.com>
     [not found]     ` <1282232786.2549.60.camel@edumazet-laptop>
     [not found]       ` <20100819161112.GA24357@Krystal>
     [not found]         ` <AANLkTinA3-KMPKJa-66QCMUpbDFwey2mjE=VN=9=zg=6@mail.gmail.com>
2010-08-20 13:43           ` [PATCH v2] netfilter: save the hash of the tuple in the original direction for latter use Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox