shithub: lwext4

Download patch

ref: 1a0b8144bddbd77d2476fec55b3d109e0e7481a0
parent: aa3c31b2b7a3ed6d7ac591292b40cde316dcde69
author: gkostka <[email protected]>
date: Thu Oct 8 15:17:53 EDT 2015

Remove some confusing casts

--- a/lwext4/ext4_xattr.c
+++ b/lwext4/ext4_xattr.c
@@ -202,7 +202,7 @@
 				   struct ext4_xattr_entry *entry,
 				   bool in_inode)
 {
-	void *ret;
+	char *ret;
 	if (in_inode) {
 		struct ext4_xattr_ibody_header *header;
 		struct ext4_xattr_entry *first_entry;
@@ -211,24 +211,19 @@
 		header = EXT4_XATTR_IHDR(xattr_ref->inode_ref->inode);
 		first_entry = EXT4_XATTR_IFIRST(header);
 
-		ret = (void *)((char *)first_entry +
-			       to_le16(entry->e_value_offs));
-		if ((char *)ret +
-			EXT4_XATTR_SIZE(to_le32(entry->e_value_size)) -
-			(char *)xattr_ref->inode_ref->inode >
-		    inode_size)
+		ret = ((char *)first_entry + to_le16(entry->e_value_offs));
+		if (ret + EXT4_XATTR_SIZE(to_le32(entry->e_value_size)) -
+			(char *)xattr_ref->inode_ref->inode > inode_size)
 			ret = NULL;
 
-	} else {
-		int32_t block_size = ext4_sb_get_block_size(&xattr_ref->fs->sb);
-		ret = (void *)((char *)xattr_ref->block.data +
-			       to_le16(entry->e_value_offs));
-		if ((char *)ret +
-			EXT4_XATTR_SIZE(to_le32(entry->e_value_size)) -
-			(char *)xattr_ref->block.data >
-		    block_size)
-			ret = NULL;
+		return ret;
+
 	}
+	int32_t block_size = ext4_sb_get_block_size(&xattr_ref->fs->sb);
+	ret = ((char *)xattr_ref->block.data + to_le16(entry->e_value_offs));
+	if (ret + EXT4_XATTR_SIZE(to_le32(entry->e_value_size)) -
+			(char *)xattr_ref->block.data > block_size)
+		ret = NULL;
 	return ret;
 }