From: Christian Brauner Date: Tue, 28 Sep 2021 09:49:26 +0000 (+0200) Subject: build: check whether compiler supports nonnull and returns_nonnull attributes X-Git-Tag: lxc-5.0.0~84^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c26176d58215dbec0c3bd93dcf86a11015cfb01;p=thirdparty%2Flxc.git build: check whether compiler supports nonnull and returns_nonnull attributes Fixes: #3980 Signed-off-by: Christian Brauner --- diff --git a/meson.build b/meson.build index 0ef787196..e37c4694b 100644 --- a/meson.build +++ b/meson.build @@ -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 ', 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) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 7ae67e30c..2fc307812 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -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"))