hdparm.c and using private kernel headers

Rob Landley rob at landley.net
Sat Mar 4 15:04:14 UTC 2006

On Saturday 04 March 2006 9:34 am, Robert P. J. Day wrote:
>   i'm assuming others can see the same warning i'm seeing when they
> select miscutils/hdparm:
>  CC miscutils/hdparm.o
> In file included from /home/rpjday/SW/busybox/miscutils/hdparm.c:48:
> /usr/include/asm/byteorder.h:6:2: warning: #warning using private
> kernel header; include <endian.h> instead!

Actually, you'll only get those kind of warnings with Mazur's kernel headers, 
but it's a good warning.

>   more a general question than anything but i'd never noticed that
> warning in a header file before.  a quick check shows that, at least
> on my FC4 system, that's the *only* header file under all of
> /usr/include that contains that warning.  (that file is part of the
> glibc-kernheaders package.)

Wow, those guys synced with Mazur?  Cool.

>   now, hdparm.c already #include's <endian.h> but you can't just
> remove the include of <asm/byteorder.h> as bad things will happen:
> applets.a(hdparm.o)(.text+0x1b7d): In function `identify_from_stdin':
> hdparm.c: undefined reference to `__le16_to_cpus'
> applets.a(hdparm.o)(.text+0x3bf2): In function `hdparm_main':
> hdparm.c: undefined reference to `__le16_to_cpus'
> collect2: ld returned 1 exit status
>   given that including <asm/byteorder.h> generates only a warning, i
> guess there's no problem with leaving it there.  but if one really
> wanted to be pedantic about this and not include private kernel header
> files that whine when they're included, the other alternative would be
> to do something like this (including the appropriate type definition
> file as well):
> #include <linux/byteorder/big_endian.h>
> #else
> #include <linux/byteorder/little_endian.h>
> #endif

A) I doubt linux/* is an improvement over asm/*.

B) The people trying to do MacOS X or cygwin support would want that in 

> (perhaps adding that to platform.h so keep it all in one place.)
>   in any event, the warning clearly doesn't stop the build but i was
> just wondering if things should be tweaked to prevent warnings like
> that one.

*shrug*.  hdparm is a fairly platform-specific tool, and essentially the 
warning is complaining that we should be doing platform-specific things in a 
portable way.

> rday

Never bet against the cheap plastic solution.

More information about the busybox mailing list