Skip to contentSkip to conversation

ext4: Use ERR_CAST to return an error-valued pointer

PATCH Applied Yu Jiaoliang 2 participants 2 messages Sep 20, 2024 – Nov 7, 2024 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Use ERR_CAST to return an error-valued pointer

Instead of directly casting and returning an error-valued pointer, use ERR_CAST to make the error handling more explicit and improve code clarity.

---
 fs/ext4/namei.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/namei.c +2 -2
index 790db7eac6c2..cb9db1e82099 100644
@@ -1747,7 +1747,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
 #endif
 	frame = dx_probe(fname, dir, NULL, frames);
 	if (IS_ERR(frame))
-		return (struct buffer_head *) frame;
+		return ERR_CAST(frame);
 	do {
 		block = dx_get_block(frame->at);
 		bh = ext4_read_dirblock(dir, block, DIRENT_HTREE);
@@ -1952,7 +1952,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
 	if (IS_ERR(bh2)) {
 		brelse(*bh);
 		*bh = NULL;
-		return (struct ext4_dir_entry_2 *) bh2;
+		return ERR_CAST(bh2);
 	}
 
 	BUFFER_TRACE(*bh, "get_write_access");
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Yu Jiaoliang

Instead of directly casting and returning an error-valued pointer, use ERR_CAST to make the error handling more explicit and improve code clarity.

Applied, thanks!

[1/1] ext4: Use ERR_CAST to return an error-valued pointer

      commit: 046c72654ae5660746ac8ce10c534d99ae35cf4f

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>