Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
C23: first round at using __has_include
Baptiste Daroussin committed 3 months ago
commit 0f84b8300eb60bfbdd1f62442d8205611f2fecc0
parent 32a1ebd
17 files changed +33 -46
modified auto.def
@@ -213,8 +213,8 @@ if {![cc-check-functions dlclose]} {
	}
}

-
cc-check-includes link.h machine/endian.h osreldate.h readpassphrase.h \
-
	sys/procctl.h sys/statfs.h sys/statvfs.h libutil.h
+
cc-check-includes link.h machine/endian.h readpassphrase.h \
+
	sys/procctl.h sys/statfs.h libutil.h

# for compat
cc-check-includes dirent.h sys/sockio.h
modified libpkg/binfmt_macho.c
@@ -27,11 +27,11 @@
#include "pkg_config.h"
#endif

-
#ifdef HAVE_SYS_ENDIAN_H
+
#if __has_include(<sys/endian.h>)
#include <sys/endian.h>
-
#elif HAVE_ENDIAN_H
+
#elif __has_include(<endian.h>)
#include <endian.h>
-
#elif HAVE_MACHINE_ENDIAN_H
+
#elif __has_include(<machine/endian.h>)
#include <machine/endian.h>
#endif
#include <errno.h>
modified libpkg/lua_scripts.c
@@ -4,9 +4,7 @@
 * SPDX-License-Identifier: BSD-2-Clause
 */

-
#include "pkg_config.h"
-

-
#ifdef HAVE_SYS_PROCCTL_H
+
#if __has_include(<sys/procctl.h>)
#include <sys/procctl.h>
#endif

modified libpkg/pkg_config.c
@@ -37,7 +37,7 @@
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
-
#ifdef HAVE_OSRELDATE_H
+
#if __has_include(<osreldate.h>)
#include <osreldate.h>
#endif
#include <ucl.h>
modified libpkg/pkg_elf.c
@@ -9,11 +9,11 @@
#include "pkg_config.h"
#endif

-
#ifdef HAVE_SYS_ENDIAN_H
+
#if __has_include(<sys/endian.h>)
#include <sys/endian.h>
-
#elif HAVE_ENDIAN_H
+
#elif __has_include(<endian.h>)
#include <endian.h>
-
#elif HAVE_MACHINE_ENDIAN_H
+
#elif __has_include(<machine/endian.h>)
#include <machine/endian.h>
#endif
#include <sys/types.h>
modified libpkg/pkg_jobs.c
@@ -29,10 +29,6 @@
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

-
#ifdef HAVE_CONFIG_H
-
#include "pkg_config.h"
-
#endif
-

#define dbg(x, ...) pkg_dbg(PKG_DBG_JOBS, x, __VA_ARGS__)

#include <bsd_compat.h>
@@ -45,7 +41,7 @@
#include <archive_entry.h>
#include <assert.h>
#include <errno.h>
-
#ifdef HAVE_LIBUTIL_H
+
#if __has_include(<libutil.h>)
#include <libutil.h>
#endif
#include <search.h>
@@ -55,11 +51,13 @@
#include <sys/wait.h>
#include <ctype.h>

-
#ifdef HAVE_SYS_STATFS_H
+
#if __has_include(<sys/statfs.h>)
#include <sys/statfs.h>
+
#define HAVE_SYS_STATFS_H 1
#endif
-
#if defined(HAVE_SYS_STATVFS_H)
+
#if __has_include(<sys/statvfs.h>)
#include <sys/statvfs.h>
+
#define HAVE_SYS_STATVFS_H 1
#endif

#include "pkg.h"
@@ -2252,7 +2250,7 @@ pkg_jobs_fetch(struct pkg_jobs *j)
	if (dlsize == 0)
		return (EPKG_OK);

-
#ifdef HAVE_FSTATFS
+
#ifdef HAVE_SYS_STATFS_H
	struct statfs fs;
	while (statfs(cachedir, &fs) == -1) {
		if (errno == ENOENT) {
modified libpkg/pkg_jobs_universe.c
@@ -32,7 +32,7 @@

#include <assert.h>
#include <errno.h>
-
#ifdef HAVE_LIBUTIL_H
+
#if __has_include(<libutil.h>)
#include <libutil.h>
#endif
#include <stdbool.h>
modified libpkg/pkgdb.c
@@ -27,7 +27,7 @@
#include <errno.h>
#include <regex.h>
#include <grp.h>
-
#ifdef HAVE_LIBUTIL_H
+
#if __has_include(<libutil.h>)
#include <libutil.h>
#endif
#include <stdlib.h>
@@ -40,8 +40,9 @@

#include <sqlite3.h>

-
#if defined(HAVE_SYS_STATVFS_H)
+
#if __has_include(<sys/statvfs.h>)
#include <sys/statvfs.h>
+
#define HAVE_SYS_STATVFS_H 1
#endif

#include "pkg.h"
modified libpkg/pkgdb_iterator.c
@@ -24,7 +24,7 @@
#include <errno.h>
#include <regex.h>
#include <grp.h>
-
#ifdef HAVE_LIBUTIL_H
+
#if __has_include(<libutil.h>)
#include <libutil.h>
#endif
#include <stdlib.h>
modified libpkg/pkgdb_query.c
@@ -23,7 +23,7 @@
#include <errno.h>
#include <regex.h>
#include <grp.h>
-
#ifdef HAVE_LIBUTIL_H
+
#if __has_include(<libutil.h>)
#include <libutil.h>
#endif
#include <stdlib.h>
modified libpkg/scripts.c
@@ -26,10 +26,8 @@
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

-
#include "pkg_config.h"
-

#include <sys/wait.h>
-
#ifdef HAVE_SYS_PROCCTL_H
+
#if __has_include(<sys/procctl.h>)
#include <sys/procctl.h>
#endif

modified src/clean.c
@@ -22,7 +22,7 @@
#include <assert.h>
#include <err.h>
#include <getopt.h>
-
#ifdef HAVE_LIBUTIL_H
+
#if __has_include(<libutil.h>)
#include <libutil.h>
#endif
#include <pkg.h>
modified src/event.c
@@ -51,7 +51,7 @@
#include <errno.h>
#include <time.h>
#include <signal.h>
-
#ifdef HAVE_LIBUTIL_H
+
#if __has_include(<libutil.h>)
#include <libutil.h>
#endif

modified src/key.c
@@ -23,10 +23,6 @@
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

-
#ifdef HAVE_CONFIG_H
-
#include "pkg_config.h"
-
#endif
-

#include <sys/uio.h>

#include <bsd_compat.h>
@@ -37,9 +33,9 @@
#include <stdio.h>
#include <string.h>

-
#ifdef HAVE_READPASSPHRASE_H
+
#if __has_include(<readpassphrase.h>)
#include <readpassphrase.h>
-
#elif defined(HAVE_BSD_READPASSPHRASE_H)
+
#elif __has_include(<bsd/readpassphrase.h>)
#include <bsd/readpassphrase.h>
#else
#include "readpassphrase_compat.h"
modified src/repo.c
@@ -1,6 +1,6 @@
/*-
 * Copyright (c) 2011-2024 Baptiste Daroussin <bapt@FreeBSD.org>
-
 * 
+
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
@@ -10,7 +10,7 @@
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
-
 * 
+
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -23,19 +23,15 @@
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

-
#ifdef HAVE_CONFIG_H
-
#include "pkg_config.h"
-
#endif
-

#include <bsd_compat.h>
#include <getopt.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>

-
#ifdef HAVE_READPASSPHRASE_H
+
#if __has_include(<readpassphrase.h>)
#include <readpassphrase.h>
-
#elif defined(HAVE_BSD_READPASSPHRASE_H)
+
#elif __has_include(<bsd/readpassphrase.h>)
#include <bsd/readpassphrase.h>
#else
#include "readpassphrase_compat.h"
modified src/stats.c
@@ -32,7 +32,7 @@
#include <err.h>
#include <getopt.h>
#include <inttypes.h>
-
#ifdef HAVE_LIBUTIL_H
+
#if __has_include(<libutil.h>)
#include <libutil.h>
#endif
#include <stdio.h>
modified src/utils.c
@@ -19,7 +19,7 @@
#include <fcntl.h>
#include <grp.h>
#include <inttypes.h>
-
#ifdef HAVE_LIBUTIL_H
+
#if __has_include(<libutil.h>)
#include <libutil.h>
#endif
#include <string.h>