commit: b2f246b5a879de21b1ae08b2498fdc29fe11c7af
parent e7f38751a31cc8c929e67a082776b3787e0d71ae
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 17 Mar 2025 19:20:23 +0100
cmd/getconf: gracefully handle confstr/sysconf variable names being undefined
Diffstat:
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/cmd/getconf_vars.m4 b/cmd/getconf_vars.m4
@@ -4,11 +4,20 @@ dnl SPDX-License-Identifier: MPL-2.0
dnl
dnl Usage: m4 cmd/getconf_vars.m4 > cmd/getconf_vars.h
dnl
-define(`conf_var', ` {$1, $2, -1},')dnl
+define(`conf_var', `#ifdef $2
+ {$1, $2, -1},
+#else
+#warning conf variable name $2 undefined
+#endif
+')dnl
define(`conf_var_limit', `#ifndef $3
#define $3 -1
#endif
+#ifdef $2
{$1, $2, $3},
+#else
+#warning conf variable name $2 undefined
+#endif
')dnl
struct conf_vars
@@ -105,14 +114,10 @@ conf_var("_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED)
conf_var("_POSIX_NO_TRUNC", _PC_NO_TRUNC)
conf_var("_POSIX_VDISABLE", _PC_VDISABLE)
conf_var("_POSIX_ASYNC_IO", _PC_ASYNC_IO)
-#ifdef _PC_FALLOC
conf_var("_POSIX_FALLOC", _PC_FALLOC)
-#endif
conf_var("_POSIX_PRIO_IO", _PC_PRIO_IO)
conf_var("_POSIX_SYNC_IO", _PC_SYNC_IO)
-#ifdef _PC_TIMESTAMP_RESOLUTION
conf_var("_POSIX_TIMESTAMP_RESOLUTION", _PC_TIMESTAMP_RESOLUTION)
-#endif
};
static const struct conf_vars sysconf_vars[] = {
@@ -268,6 +273,8 @@ conf_var("XOPEN_UNIX", _SC_XOPEN_UNIX)
#ifdef _SC_XOPEN_UUCP // added in POSIX.1-2008, strangely missing from musl
conf_var("_XOPEN_UUCP", _SC_XOPEN_UUCP)
conf_var("XOPEN_UUCP", _SC_XOPEN_UUCP)
+#else
+#warning sysconf variable _SC_XOPEN_UUCP undefined
#endif
conf_var("_XOPEN_VERSION", _SC_XOPEN_VERSION)
#ifdef _SC_CHARCLASS_NAME_MAX
@@ -280,7 +287,8 @@ define(`limits_var', `#ifdef $1
{"$1", $1},
#else
#warning limits.h variable $1 undefined
-#endif')dnl
+#endif
+')dnl
define(`limits_var_alias', ` {"$1", $2},')dnl
// _MIN and _MAX from <limits.h>
static const struct limits limits_vars[] = {