Re: kdump: resolve sysctl numbers

2011-07-27 Thread Ted Unangst
On Wed, Jul 27, 2011, Otto Moerbeek wrote:

 +#define SETNAME(name) do { names = (name); limit = nitems(name); } while (0)

userland is not supposed to use nitems I think?  But it keeps sneaking
in because the kernel headers don't protect it.



Re: kdump: resolve sysctl numbers

2011-07-27 Thread Otto Moerbeek
On Wed, Jul 27, 2011 at 10:58:22AM -0400, Ted Unangst wrote:

 On Wed, Jul 27, 2011, Otto Moerbeek wrote:
 
  +#define SETNAME(name) do { names = (name); limit = nitems(name); } while 
  (0)
 
 userland is not supposed to use nitems I think?  But it keeps sneaking
 in because the kernel headers don't protect it.

Well, I thought it's ok here since kdump already has it's
fingers into the kernel jar anyway. 

-Otto



Re: kdump: resolve sysctl numbers

2011-07-27 Thread Jasper Lievisse Adriaanse
On Wed, Jul 27, 2011 at 10:58:22AM -0400, Ted Unangst wrote:
 On Wed, Jul 27, 2011, Otto Moerbeek wrote:
 
  +#define SETNAME(name) do { names = (name); limit = nitems(name); } while 
  (0)
 
 userland is not supposed to use nitems I think?  But it keeps sneaking
 in because the kernel headers don't protect it.
That's right. It's used in some places like pcidump, npppd and tmux, but it's
locally defined as:

#ifndef nitems
#define nitems(_a)  (sizeof((_a)) / sizeof((_a)[0]))
#endif

-- 
Cheers,
Jasper

Capable, generous men do not create victims, they nurture them.



Re: kdump: resolve sysctl numbers

2011-07-27 Thread Thordur Bjornsson
On 2011 Jul 27 (Wed) at 19:22:34 +0200 (+0200), Jasper Lievisse Adriaanse wrote:
 On Wed, Jul 27, 2011 at 10:58:22AM -0400, Ted Unangst wrote:
  On Wed, Jul 27, 2011, Otto Moerbeek wrote:
  
   +#define SETNAME(name) do { names = (name); limit = nitems(name); } while 
   (0)
  
  userland is not supposed to use nitems I think?  But it keeps sneaking
  in because the kernel headers don't protect it.
 That's right. It's used in some places like pcidump, npppd and tmux, but it's
 locally defined as:
 
 #ifndef nitems
 #define nitems(_a)(sizeof((_a)) / sizeof((_a)[0]))
 #endif

What is the reason for this not being kosher yet,
and if it's not ment to be, why isn't it protected by _KERNEL ?