From d3368ee0d5c71c960ec01db31599970773fe12b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sun, 2 Nov 2025 19:06:39 +0100 Subject: [PATCH] spa: utils: cleanup: fix `__has_attribute()` usage Unknown preprocessor symbols are replaced with 0 in preprocessor conditionals, so if `__has_attribute()` is not supported, then the condition will be the following: if 0 && 0(__cleanup__) which is syntactically incorrect. So split the condition and only check `__has_attribute()` if it exists. Fixes: 65d949558b552a ("spa: utils: add scope based resource cleanup") Fixes #4962 --- spa/include/spa/utils/cleanup.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spa/include/spa/utils/cleanup.h b/spa/include/spa/utils/cleanup.h index 23fb8e150..75bbfe0bc 100644 --- a/spa/include/spa/utils/cleanup.h +++ b/spa/include/spa/utils/cleanup.h @@ -46,9 +46,13 @@ __extension__ ({ \ /* ========================================================================== */ -#if defined(__has_attribute) && __has_attribute(__cleanup__) - +#ifdef __has_attribute +#if __has_attribute(__cleanup__) #define spa_cleanup(func) __attribute__((__cleanup__(func))) +#endif +#endif + +#ifdef spa_cleanup #define SPA_DEFINE_AUTO_CLEANUP(name, type, ...) \ typedef __typeof__(type) _spa_auto_cleanup_type_ ## name; \