public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] adfs: Fix incorrect unsigned return type in adfs_f_getnext()
@ 2025-12-03  6:51 Haotian Zhang
  2025-12-03  9:13 ` Russell King (Oracle)
  0 siblings, 1 reply; 2+ messages in thread
From: Haotian Zhang @ 2025-12-03  6:51 UTC (permalink / raw)
  To: rmk+kernel; +Cc: viro, linux-kernel, 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.

Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 fs/adfs/dir_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/adfs/dir_f.c b/fs/adfs/dir_f.c
index 05e963402e25..81dedb796b56 100644
--- a/fs/adfs/dir_f.c
+++ b/fs/adfs/dir_f.c
@@ -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)
-- 
2.50.1.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] adfs: Fix incorrect unsigned return type in adfs_f_getnext()
  2025-12-03  6:51 [PATCH] adfs: Fix incorrect unsigned return type in adfs_f_getnext() Haotian Zhang
@ 2025-12-03  9:13 ` Russell King (Oracle)
  0 siblings, 0 replies; 2+ messages in thread
From: Russell King (Oracle) @ 2025-12-03  9:13 UTC (permalink / raw)
  To: Haotian Zhang; +Cc: viro, linux-kernel

On Wed, Dec 03, 2025 at 02:51:20PM +0800, Haotian Zhang wrote:
> 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.
> 
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>

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

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Thanks!

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-03  9:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03  6:51 [PATCH] adfs: Fix incorrect unsigned return type in adfs_f_getnext() Haotian Zhang
2025-12-03  9:13 ` Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox