[Toybox] [PATCH] Clean warnings generated by scripts/genconfig.sh

Rob Landley rob at landley.net
Mon Feb 27 22:08:51 PST 2012


On 02/27/2012 06:45 PM, Georgi Chorbadzhiyski wrote:
> The attached patch prevents warnings related to clone flags. According
> to clone(2) _GNU_SOURCE must be defined before including <sched.h>.

Yeah, Michael Kerrisk is wrong on that one.  (That's the "big hammer"
that switches on everything glibc can do. All we _actually_ need here is
__USE_MISC.)

> After the patch the following warnings disappear:
> 
>   <stdin>:2:11: error: 'CLONE_NEWNS' undeclared here (not in a function)
>   <stdin>:2:23: error: 'CLONE_NEWUTS' undeclared here (not in a function)
>   <stdin>:2:36: error: 'CLONE_NEWIPC' undeclared here (not in a function)
>   <stdin>:2:49: error: 'CLONE_NEWNET' undeclared here (not in a function)

A) This project has nothing to do with gnu anything.  I'd rather
#declare the constants in the header than have to say that. Especially
since these constants are Linux clone flags that come out of
linux/sched.h, so the FSF was not remotely involved, and if some idiot
decided you need to define ALL_HAIL_RICHARD_STALLMAN in order to get
linux/sched.h included from bits.h they're _insane_.  (Yeah, a bit of a
sore spot with me. :)

2) An error isn't the same as a warning, and those are _errors_. The
compile failed, which it didn't for me.  What's your test environment
for building this? It worked fine for me without #defining anything special.

My /usr/include/bits/sched.h has it guarded by __USE_MISC which
features.h #defines in a lot of ways, and I seem to be getting it via
this path:

/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
   (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined).  */

At a guess, your compiler flags are feeding it "-ansi" or "-pedantic" or
some such, and forcing it to the old C89 standard from 23 years ago?
Again from /usr/include/features.h:

   The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
   If none of these are defined, the default is to have _SVID_SOURCE,
   _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
   200112L.  If more than one of these are defined, they accumulate.
   For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
   together give you ISO C, 1003.1, and 1003.2, but nothing else.

If so, that's probably the fundamental problem I should address,
possibly by setting -c99 in the default CFLAGS maybe?

III) I could also change the test to #include <linux/sched.h> instead.
Or #define _POSIX_C_SOURCE 200809L to get posix2008 which is what we're
using. There's a bunch of better ways to fix this: Toybox is a Linux
project, not a GNU project.

Rob

 1330409331.0


More information about the Toybox mailing list