hdparm.c and using private kernel headers

Robert P. J. Day rpjday at mindspring.com
Sat Mar 4 06:34:04 PST 2006


  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!

  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.)

  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):

#if BB_BIG_ENDIAN
#include <linux/byteorder/big_endian.h>
#else
#include <linux/byteorder/little_endian.h>
#endif

(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.

rday


More information about the busybox mailing list