Skip to contentSkip to conversation

xattr: simplify logic at xattr_resolve_name()

PATCH New Andriy Tkachuk 1 participant 1 message Apr 9, 2021 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xattr: simplify logic at xattr_resolve_name()

The negative case check logic with XOR operation between the two variables with negated values is really hard to comprehend. Change it to positive case check with == instead of XOR.

---
 fs/xattr.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
fs/xattr.c +6 -6
index b3444e06cd..531562535d 100644
@@ -66,13 +66,13 @@ xattr_resolve_name(struct inode *inode, const char **name)
 
 		n = strcmp_prefix(*name, xattr_prefix(handler));
 		if (n) {
-			if (!handler->prefix ^ !*n) {
-				if (*n)
-					continue;
-				return ERR_PTR(-EINVAL);
+			if (!handler->prefix == !*n) {
+				*name = n;
+				return handler;
 			}
-			*name = n;
-			return handler;
+			if (*n)
+				continue;
+			return ERR_PTR(-EINVAL);
 		}
 	}
 	return ERR_PTR(-EOPNOTSUPP);
Signature · 1 line
2.27.0