linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* unhappy with current.h
@ 2002-10-14 19:46 Daniele Lugli
  2002-10-14 19:52 ` David S. Miller
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Daniele Lugli @ 2002-10-14 19:46 UTC (permalink / raw)
  To: linux-kernel

I recently wrote a kernel module which gave me some mysterious problems.
After too many days spent in blood, sweat and tears, I found the cause:

*** one of my data structures has a field named 'current'. ***

Pretty common word, isn't it? Would you think it can cause such a
trouble? But in some of my files I happen to indirectly include
<asm/current.h> (kernel 2.4.18 for i386), containing the following line:

#define current get_current()

so that my structure becomes the owner of a function it has never asked
for, while it looses a data member. gcc has nothing to complain about
that.

In some other files I don't happen to include <asm/current.h>, so that
there my structure is sound - but alas! has different size and different
composition. Again, gcc has nothing to complain.

Moral of the story: in my opinion kernel developers should reduce to a
minimum the use of #define, and preferably use words in uppercase and/or
with underscores, in any case not commonly used words.
In the specific case the said #define just looks to save 6 keystrokes
and I think it could have been completely avoided.

Regards, Daniele Lugli

^ permalink raw reply	[flat|nested] 21+ messages in thread
[parent not found: <20021014.161535.17120.336861@webmail4.nyc.untd.com>]
* Re: unhappy with current.h
@ 2002-10-18 14:49 Jeffrey Lim
  0 siblings, 0 replies; 21+ messages in thread
From: Jeffrey Lim @ 2002-10-18 14:49 UTC (permalink / raw)
  To: David S. Miller, genlogic; +Cc: linux-kernel


On Mon, 14 Oct 2002 12:52:34 -0700 (PDT), "David S. Miller"
<davem@redhat.com> said:
>
>        From: Daniele Lugli <genlogic@inrete.it>
>        Date: Mon, 14 Oct 2002 21:46:08 +0200
>    
>        Moral of the story: in my opinion kernel developers should reduce to a
>        minimum the use of #define, and preferably use words in uppercase
>        and/or with underscores, in any case not commonly used words.
> 
> Or maybe you should change your datastructure to not have member names
> the conflict with 7 year old well defined global symbols in the Linux
> kernel?
>

I guess tradition may have been well established. Is there an faq for
this somewhere (for these "well defined global symbols", that is) that we
could perhaps refer to?

I do believe he has a point though. It would be good to watch the
#defines in the future, so as to make it easier for aspiring coders.

-jf
 
#!/bin/signoff
# ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
echo The reasonable man adapts himself to the world; the unreasonable one
echo persists in trying to adapt the world to himself. Therefore, all
echo progress depends on the unreasonable.
echo                                              — George Bernard Shaw
# ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
 
 

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2002-10-18 14:44 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-14 19:46 unhappy with current.h Daniele Lugli
2002-10-14 19:52 ` David S. Miller
2002-10-14 20:18   ` Daniele Lugli
2002-10-14 20:24 ` Chris Wedgwood
2002-10-15  0:00   ` Rik van Riel
2002-10-15  1:05     ` Chris Wedgwood
2002-10-15  1:12     ` Murray J. Root
2002-10-15 14:11     ` Mikael Pettersson
2002-10-15 20:29       ` Daniele Lugli
2002-10-15 20:44         ` Alexander Viro
2002-10-15 21:01         ` Mikael Pettersson
2002-10-14 20:33 ` Richard B. Johnson
2002-10-14 20:33   ` David S. Miller
2002-10-14 20:37   ` Olivier Galibert
2002-10-15 18:31     ` Richard B. Johnson
2002-10-14 21:22   ` Daniele Lugli
2002-10-15 17:08     ` Richard B. Johnson
2002-10-14 20:45 ` Andi Kleen
2002-10-15  1:09   ` Chris Wedgwood
     [not found] <20021014.161535.17120.336861@webmail4.nyc.untd.com>
2002-10-14 20:24 ` Daniele Lugli
2002-10-18 14:49 Jeffrey Lim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).