Skip to contentSkip to conversation

erofs-utils: fix erofs_sys_lsetxattr() returning positive errno

PATCH In review Zhan Xusheng 3 participants 4 messages Apr 7 – Apr 9 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: fix erofs_sys_lsetxattr() returning positive errno

erofs_sys_lsetxattr() returns bare errno (a positive value) on failure, unlike its sibling erofs_sys_lgetxattr() which correctly returns -errno.

Fix by returning -errno, consistent with erofs_sys_lgetxattr().

Fixes e0d85fc5a282 ("erofs-utils: lib: introduce erofs_sys_lsetxattr()")
---
 lib/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/xattr.c +1 -1
index 565070a..af1b9ca 100644
@@ -123,7 +123,7 @@ ssize_t erofs_sys_lsetxattr(const char *path, const char *name,
 	errno = ENODATA;
 #endif
 	if (ret < 0)
-		return errno;
+		return -errno;
 	return ret;
 }
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 17 lines · Zhan Xusheng

erofs_sys_lsetxattr() returns bare errno (a positive value) on failure, unlike its sibling erofs_sys_lgetxattr() which correctly returns -errno.

Fix by returning -errno, consistent with erofs_sys_lgetxattr().

Fixes e0d85fc5a282 ("erofs-utils: lib: introduce erofs_sys_lsetxattr()")
---
 lib/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/xattr.c +0 -0
index 565070a..af1b9ca 100644

lib/xattr.c ssize_t erofs_sys_lsetxattr(const char *path, const char *name, · line 129

Quoted 8 lines
lib/xattr.c +1 -1
@@ -123,7 +123,7 @@ ssize_t erofs_sys_lsetxattr(const char *path, const char *name,
 	errno = ENODATA;
 #endif
 	if (ret < 0)
-		return errno;
+		return -errno;
 	return ret;
 }
 

For consistency with erofs_sys_lgetxattr():
- return errno;
+ ret = -errno;

Regards,
Lucas

#2 lore raw

Hi Lucus,

Quoted 27 lines · Lucas Karpinski
Quoted 17 lines · Zhan Xusheng

erofs_sys_lsetxattr() returns bare errno (a positive value) on failure, unlike its sibling erofs_sys_lgetxattr() which correctly returns -errno.

Fix by returning -errno, consistent with erofs_sys_lgetxattr().

Fixes e0d85fc5a282 ("erofs-utils: lib: introduce erofs_sys_lsetxattr()")
---
  lib/xattr.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/xattr.c +0 -0
index 565070a..af1b9ca 100644

lib/xattr.c ssize_t erofs_sys_lsetxattr(const char *path, const char *name, · line 129

Quoted 8 lines
lib/xattr.c +1 -1
@@ -123,7 +123,7 @@ ssize_t erofs_sys_lsetxattr(const char *path, const char *name,
  	errno = ENODATA;
  #endif
  	if (ret < 0)
-		return errno;
+		return -errno;
  	return ret;
  }
 

For consistency with erofs_sys_lgetxattr():

Review

Quoted 2 lines
(quoted diff) +1 -1
-		return errno;
+		ret = -errno;

Thanks for the suggestion, but it has been applied to -dev branch, so I have to leave it as-is (I tend to avoid rebasing -dev).

Thanks,
Gao Xiang

Quoted 3 lines

Regards,
Lucas

#3 lore raw
Quoted 5 lines · Gao Xiang

Hi Lucus,

Quoted 3 lines

For consistency with erofs_sys_lgetxattr():
-        return errno;
+        ret = -errno;

Quoted 11 lines

Thanks for the suggestion, but it has been applied to -dev branch, so I have to leave it as-is (I tend to avoid rebasing -dev).

Thanks,
Gao Xiang

Quoted 3 lines

Regards,
Lucas

No worries, was just a small nit.