Skip to contentSkip to conversation

f2fs: return success if there is no work to do

PATCH In review [email protected] 2 participants 2 messages May 15, 2021 – May 17, 2021 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: return success if there is no work to do

From: Tom Rix <[email protected]>

Static analysis reports this problem
file.c:3206:2: warning: Undefined or garbage value returned to caller

        return err;
        ^~~~~~~~~~

err is only set if there is some work to do. Because the loop returns immediately on an error, if all the work was done, a 0 would be returned. Instead of checking the unlikely case that there was no work to do, change the return of err to 0.

---
 fs/f2fs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +1 -1
index ceb575f99048c..bae0f910f5f0a 100644
@@ -3203,7 +3203,7 @@ int f2fs_precache_extents(struct inode *inode)
 		map.m_lblk = m_next_extent;
 	}
 
-	return err;
+	return 0;
 }
 
 static int f2fs_ioc_precache_extents(struct file *filp, unsigned long arg)
Signature · 1 line
2.26.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · On 2021/5/16 2:09, [email protected] wrote:

From: Tom Rix <[email protected]>

Static analysis reports this problem
file.c:3206:2: warning: Undefined or garbage value returned to caller

         return err;
         ^~~~~~~~~~
Quoted 6 lines

err is only set if there is some work to do. Because the loop returns immediately on an error, if all the work was done, a 0 would be returned. Instead of checking the unlikely case that there was no work to do, change the return of err to 0.

Thanks,