[PATCH v7 01/13] erofs-utils: lib: remove unneeded NULL checks

Gao Xiang hsiangkao at linux.alibaba.com
Sun Sep 10 02:32:28 AEST 2023


From: Jingbo Xu <jefflexu at linux.alibaba.com>

get_xattritem() will in no way return NULL.  Use DBG_BUGONs instead.

Signed-off-by: Jingbo Xu <jefflexu at linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/xattr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/xattr.c b/lib/xattr.c
index 0cab29f..2b7c634 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -437,8 +437,7 @@ int erofs_setxattr(struct erofs_inode *inode, char *key,
 	item = get_xattritem(prefix, kvbuf, len);
 	if (IS_ERR(item))
 		return PTR_ERR(item);
-	if (!item)
-		return 0;
+	DBG_BUGON(!item);
 
 	return erofs_xattr_add(&inode->i_xattrs, item);
 }
@@ -473,8 +472,7 @@ static int erofs_droid_xattr_set_caps(struct erofs_inode *inode)
 	item = get_xattritem(EROFS_XATTR_INDEX_SECURITY, kvbuf, len);
 	if (IS_ERR(item))
 		return PTR_ERR(item);
-	if (!item)
-		return 0;
+	DBG_BUGON(!item);
 
 	return erofs_xattr_add(&inode->i_xattrs, item);
 }
-- 
2.24.4



More information about the Linux-erofs mailing list