From 2631cb6dd1dab8275752bdf3ecd076cf60765faf Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Fri, 1 Sep 2023 22:56:53 +0200 Subject: [PATCH] always define _GNU_SOURCE and _DEFAULT_SOURCE --- bin/xbps-fbulk/main.c | 2 -- bin/xbps-query/search.c | 6 ------ bin/xbps-uchroot/main.c | 30 +++++++++++++++--------------- bin/xbps-uunshare/main.c | 25 +++++++++++++------------ configure | 3 ++- lib/cb_util.c | 4 ---- lib/external/dewey.c | 2 -- lib/external/fexec.c | 8 ++------ lib/fetch/ftp.c | 5 ----- lib/fetch/http.c | 4 ---- lib/portableproplib/prop_object.c | 4 +--- lib/util.c | 12 +----------- 12 files changed, 34 insertions(+), 71 deletions(-) diff --git a/bin/xbps-fbulk/main.c b/bin/xbps-fbulk/main.c index 4bd10b055..e54bea177 100644 --- a/bin/xbps-fbulk/main.c +++ b/bin/xbps-fbulk/main.c @@ -47,8 +47,6 @@ * Only one attempt is made to build any given package, no matter how many * other packages depend on it. */ -#define _DEFAULT_SOURCE -#define _BSD_SOURCE #include #include diff --git a/bin/xbps-query/search.c b/bin/xbps-query/search.c index bf1bac27f..98bd4c1d9 100644 --- a/bin/xbps-query/search.c +++ b/bin/xbps-query/search.c @@ -23,12 +23,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef HAVE_STRCASESTR -# define _GNU_SOURCE /* for strcasestr(3) */ -#endif - -#include "compat.h" - #include #include #include diff --git a/bin/xbps-uchroot/main.c b/bin/xbps-uchroot/main.c index 410afe3b7..fefa65a02 100644 --- a/bin/xbps-uchroot/main.c +++ b/bin/xbps-uchroot/main.c @@ -32,28 +32,28 @@ * - Supports overlayfs on a temporary directory or a tmpfs mount. * - Supports read-only bind mounts. */ -#define _GNU_SOURCE -#define _XOPEN_SOURCE 700 -#include -#include + #include #include +#include #include +#include #include -#include -#include -#include -#include -#include -#include + #include -#include -#include -#include /* PATH_MAX */ +#include +#include +#include #include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include "queue.h" diff --git a/bin/xbps-uunshare/main.c b/bin/xbps-uunshare/main.c index ac257d383..8e0f5a270 100644 --- a/bin/xbps-uunshare/main.c +++ b/bin/xbps-uunshare/main.c @@ -22,25 +22,26 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define _GNU_SOURCE -#include -#include + #include +#include +#include #include + +#include +#include +#include +#include +#include +#include #include +#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include +#include #include #include "queue.h" diff --git a/configure b/configure index 516a32ba0..b5fce521d 100755 --- a/configure +++ b/configure @@ -219,9 +219,10 @@ if [ -n "$FULL_DEBUG" ]; then echo "CPPFLAGS+= -DFULL_DEBUG" >>$CONFIG_MK fi +echo "CPPFLAGS += -D_DEFAULT_SOURCE" >>$CONFIG_MK +echo "CPPFLAGS += -D_GNU_SOURCE" >>$CONFIG_MK case "$OS" in linux) - echo "CPPFLAGS += -D_XOPEN_SOURCE=700" >>$CONFIG_MK echo "CPPFLAGS += -D_FILE_OFFSET_BITS=64" >> $CONFIG_MK ;; *) diff --git a/lib/cb_util.c b/lib/cb_util.c index 1aa0f073e..35fbaa77e 100644 --- a/lib/cb_util.c +++ b/lib/cb_util.c @@ -23,10 +23,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef HAVE_VASPRINTF -# define _GNU_SOURCE /* for vasprintf(3) */ -#endif - #include #include #include diff --git a/lib/external/dewey.c b/lib/external/dewey.c index 80977d9ce..033d2c158 100644 --- a/lib/external/dewey.c +++ b/lib/external/dewey.c @@ -31,9 +31,7 @@ #include #include #include -#define _BSD_SOURCE #include -#undef _BSD_SOURCE #include #include diff --git a/lib/external/fexec.c b/lib/external/fexec.c index 11c40120a..8de8ad039 100644 --- a/lib/external/fexec.c +++ b/lib/external/fexec.c @@ -27,19 +27,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#define _BSD_SOURCE /* for vfork and chroot */ -#define _DEFAULT_SOURCE /* glibc>=2.20 */ #include -#include - #include + #include #include #include #include +#include -#undef _DEFAULT_SOURCE -#undef _BSD_SOURCE #include "xbps_api_impl.h" static int diff --git a/lib/fetch/ftp.c b/lib/fetch/ftp.c index 28296a009..9986a57e2 100644 --- a/lib/fetch/ftp.c +++ b/lib/fetch/ftp.c @@ -57,11 +57,6 @@ * */ -#ifdef __linux__ -/* Keep this down to Linux, it can create surprises else where. */ -#define _GNU_SOURCE -#endif - #include #include diff --git a/lib/fetch/http.c b/lib/fetch/http.c index 0165de32c..e0832865c 100644 --- a/lib/fetch/http.c +++ b/lib/fetch/http.c @@ -62,10 +62,6 @@ * SUCH DAMAGE. */ -#if defined(__linux__) -#define _GNU_SOURCE -#endif - #include #include diff --git a/lib/portableproplib/prop_object.c b/lib/portableproplib/prop_object.c index 2e2a7c9d7..daac88cf6 100644 --- a/lib/portableproplib/prop_object.c +++ b/lib/portableproplib/prop_object.c @@ -36,9 +36,7 @@ static pthread_mutex_t _prop_refcnt_mtx = PTHREAD_MUTEX_INITIALIZER; #endif /* _PROP_NEED_REFCNT_MTX */ -#define __USE_MISC /* MAP_ANON on glibc */ -# include -#undef __USE_MISC +#include #include #include #include diff --git a/lib/util.c b/lib/util.c index 2e29d4d5e..d5722ef42 100644 --- a/lib/util.c +++ b/lib/util.c @@ -22,17 +22,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifdef HAVE_VASPRINTF -# define _GNU_SOURCE /* for vasprintf(3) */ -#endif - -#if defined(HAVE_STRLCAT) || defined(HAVE_STRLCPY) -# define _BSD_SOURCE -#endif - -#include "compat.h" - #include #include @@ -47,6 +36,7 @@ #include #include +#include "compat.h" #include "xbps_api_impl.h" #ifdef __clang__