From e018b53142d17ee92d59cc310d499cc4077ac24e Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Tue, 28 May 2024 10:40:44 +0200 Subject: [PATCH] scons: check *xattr functions with correct arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `SCons.Conftest.CheckFunc(context, "lgetxattr", "#include \n#include ")` will generate following C code: ``` #include #include #include #if _MSC_VER && !__INTEL_COMPILER #pragma function(lgetxattr) #endif int main(void) { #if defined (__stub_lgetxattr) || defined (__stub___lgetxattr) #error "lgetxattr has a GNU stub, cannot check" #else lgetxattr(); #endif return 0; } ``` This code snippet will fail to compile on armhf on Ubuntu 24.04 (noble): ``` $ gcc -o test test.c test.c: In function ‘main’: test.c:13:11: error: too few arguments to function ‘lgetxattr’ 13 | lgetxattr(); | ^~~~~~~~~ In file included from test2.c:3: /usr/include/arm-linux-gnueabihf/sys/xattr.h:67:16: note: declared here 67 | extern ssize_t lgetxattr (const char *__path, const char *__name, | ^~~~~~~~~ ``` So pass valid arguments to the *xttr functions. **Note**: The `funcargs` parameter requires SCons >= 4.7.0! Bug-Ubuntu: https://launchpad.net/bugs/2066970 --- SConstruct | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 23b112ef..cf643d29 100755 --- a/SConstruct +++ b/SConstruct @@ -270,9 +270,14 @@ def check_posix_fadvise(context): def check_xattr(context): rc = 1 - for func in ['getxattr', 'setxattr', 'removexattr', 'listxattr']: + for func, funcargs in ( + ('getxattr', '"path", "name", 0, 0'), + ('setxattr', '"path", "name", 0, 0, 0'), + ('removexattr', '"path", "name"'), + ('listxattr', '"path", "name", 0'), + ): if tests.CheckFunc( - context, func, + context, func, funcargs=funcargs, header= '#include ' '#include ' @@ -291,9 +296,14 @@ def check_xattr(context): def check_lxattr(context): rc = 1 - for func in ['lgetxattr', 'lsetxattr', 'lremovexattr', 'llistxattr']: + for func, funcargs in ( + ('lgetxattr', '"path", "name", 0, 0'), + ('lsetxattr', '"path", "name", 0, 0, 0'), + ('lremovexattr', '"path", "name"'), + ('llistxattr', '"path", "name", 0'), + ): if tests.CheckFunc( - context, func, + context, func, funcargs=funcargs, header= '#include ' '#include '