Subject: misc/21317: abuses _POSIX_SOURCE
To: None <gnats-bugs@gnats.netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: netbsd-bugs
Date: 04/25/2003 11:49:35
>Number:         21317
>Category:       misc
>Synopsis:       <sys/midiio.h> abuses _POSIX_SOURCE
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 25 10:50:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Ben Harris
>Release:        2003-04-25
>Organization:
>Environment:
>Description:
<sys/midiio.h> includes the following:

#ifndef _POSIX_SOURCE
#define __MIDIIO_UNSET_POSIX_SOURCE
#define _POSIX_SOURCE           /* make sure we don't get all the gunk */
#endif
#include <machine/endian.h>
#ifdef __MIDIIO_UNSET_POSIX_SOURCE
#undef _POSIX_SOURCE
#undef __MIDIIO_UNSET_POSIX_SOURCE
#endif

This is horribly broken, since it means that if the user subsequently
includes <machine/endian.h> themselves, they won't get any of the extra
NetBSD facilities it provides.  If it's necessary to avoid trampling the
user's namespace when using <sys/midiio.h>, then this should be done by
either splitting <sys/endian.h> into "clean" and "dirty" halves, or by
using the feature-test macro for whatever standard defines <sys/midiio.h>.

>How-To-Repeat:
Code inspection.  The only header that has _any_ business modifying
feature-test macros is <sys/featuretest.h>.  Everything else should treat
them as read-only.

>Fix:



>Release-Note:
>Audit-Trail:
>Unformatted: