]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
build: check whether compiler supports nonnull and returns_nonnull attributes 3981/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 28 Sep 2021 09:49:26 +0000 (11:49 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 28 Sep 2021 09:49:26 +0000 (11:49 +0200)
Fixes: #3980
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
meson.build
src/lxc/cgroups/cgfsng.c

index 0ef787196d79dbd82f2328c12c24c6b14adf9513..e37c4694bb5ac82df508e7904d3422607313c461 100644 (file)
@@ -13,7 +13,7 @@ project('lxc', 'c',
                 'c_std=gnu11',
                 'warning_level=2',
         ],
-        meson_version : '>= 0.46',
+        meson_version : '>= 0.48',
        )
 
 liblxc_version = '4.0.0'
@@ -355,6 +355,9 @@ conf.set10('HAVE_STRCHRNUL', have)
 have = cc.has_function('openpty', prefix : '#include <pty.h>', args : '-D_GNU_SOURCE')
 conf.set10('HAVE_OPENPTY', have)
 
+conf.set10('HAVE_COMPILER_ATTR_NONNULL', cc.has_function_attribute('nonnull'))
+conf.set10('HAVE_COMPILER_ATTR_RETURNS_NONNULL', cc.has_function_attribute('returns_nonnull'))
+
 config_h = configure_file(
         output : 'config.h',
         configuration : conf)
index 7ae67e30c72ce4440309e3dc1e976682a29ac73a..2fc30781295fc04e036c43d1fe830f5659d74d7e 100644 (file)
@@ -3116,7 +3116,12 @@ static bool legacy_hierarchy_delegated(int dfd_base)
  * Ensure that we always use the systemd-guaranteed stable order when checking
  * for the mountpoint.
  */
-__attribute__((returns_nonnull)) __attribute__((nonnull))
+#if HAVE_COMPILER_ATTR_NONNULL
+__attribute__((nonnull))
+#endif
+#if HAVE_COMPILER_ATTR_RETURNS_NONNULL
+__attribute__((returns_nonnull))
+#endif
 static const char *stable_order(const char *controllers)
 {
        if (strequal(controllers, "cpuacct,cpu"))