git: 8ad097de0226 - main - linuxulator: Fix operator precedence for LINUX_XATTR_FLAGS in setxattr()

From: Pouria Mousavizadeh Tehrani <pouria_at_FreeBSD.org>
Date: Thu, 02 Jul 2026 11:17:26 UTC
The branch main has been updated by pouria:

URL: https://cgit.FreeBSD.org/src/commit/?id=8ad097de02263d92df3368a2f5035faa365e7956

commit 8ad097de02263d92df3368a2f5035faa365e7956
Author:     YAO, Xin <mr.yaoxin@outlook.com>
AuthorDate: 2026-07-01 20:10:13 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-07-02 11:17:01 +0000

    linuxulator: Fix operator precedence for LINUX_XATTR_FLAGS in setxattr()
    
    The LINUX_XATTR_FLAGS macro expands to (LINUX_XATTR_CREATE|LINUX_XATTR_REPLACE).
    Without parentheses around the macro expansion, the bitwise & operator has
    higher precedence than |, causing incorrect flag evaluation and a compiler
    warning.
    
    Add the missing parentheses around LINUX_XATTR_FLAGS to ensure correct
    operator grouping, matching the existing usage in getxattr().
    
    Signed-off-by:  YAO, Xin <mr.yaoxin@outlook.com>
    Fixes:          2c905456312b ("linuxulator: Fix O_PATH file descriptors errno for f*xattr(2)")
    Reviewed by:    kib
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2306
---
 sys/compat/linux/linux_xattr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/compat/linux/linux_xattr.c b/sys/compat/linux/linux_xattr.c
index 296b70ff409a..9a206089ada1 100644
--- a/sys/compat/linux/linux_xattr.c
+++ b/sys/compat/linux/linux_xattr.c
@@ -53,7 +53,7 @@
 
 #define	LINUX_XATTR_CREATE	0x1
 #define	LINUX_XATTR_REPLACE	0x2
-#define	LINUX_XATTR_FLAGS	LINUX_XATTR_CREATE|LINUX_XATTR_REPLACE
+#define	LINUX_XATTR_FLAGS	(LINUX_XATTR_CREATE | LINUX_XATTR_REPLACE)
 
 struct listxattr_args {
 	int		fd;
@@ -511,8 +511,8 @@ setxattr(struct thread *td, struct setxattr_args *args)
 			return (error);
 	}
 
-	if ((args->flags & ~(LINUX_XATTR_FLAGS)) != 0 ||
-	    args->flags == (LINUX_XATTR_FLAGS)) {
+	if ((args->flags & ~LINUX_XATTR_FLAGS) != 0 ||
+	    args->flags == LINUX_XATTR_FLAGS) {
 		error = EINVAL;
 		goto out_err;
 	}
@@ -520,7 +520,7 @@ setxattr(struct thread *td, struct setxattr_args *args)
 	if (error != 0)
 		goto out_err;
 
-	if ((args->flags & (LINUX_XATTR_FLAGS)) != 0 ) {
+	if ((args->flags & LINUX_XATTR_FLAGS) != 0) {
 		if (args->path != NULL)
 			error = kern_extattr_get_path(td, args->path,
 			    attrnamespace, attrname, NULL, args->size,