Skip to contentSkip to conversation

adfs: Fix incorrect unsigned return type in adfs_f_getnext()

PATCH In review Haotian Zhang 2 participants 2 messages Dec 3, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 adfs: Fix incorrect unsigned return type in adfs_f_getnext()

adfs_f_getnext() stores the return value of __adfs_dir_get() into an unsigned int. Since __adfs_dir_get() may return negative error codes such as -ENOENT, these values are converted into large positive numbers.

Change the return variable to type int to correctly preserve and return negative error codes.

---
 fs/adfs/dir_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/adfs/dir_f.c +1 -1
index 05e963402e25..81dedb796b56 100644
@@ -242,7 +242,7 @@ adfs_f_setpos(struct adfs_dir *dir, unsigned int fpos)
 static int
 adfs_f_getnext(struct adfs_dir *dir, struct object_info *obj)
 {
-	unsigned int ret;
+	int ret;
 
 	ret = __adfs_dir_get(dir, dir->pos, obj);
 	if (ret == 0)
Signature · 1 line
2.50.1.windows.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Haotian Zhang

adfs_f_getnext() stores the return value of __adfs_dir_get() into an unsigned int. Since __adfs_dir_get() may return negative error codes such as -ENOENT, these values are converted into large positive numbers.

Change the return variable to type int to correctly preserve and return negative error codes.

The real problem here is the unsigned int -> int conversion, which is implementation defined in C. int -> unsigned int itself is well defined.

Thanks!

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!