summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorngkaho1234 <ngkaho1234@gmail.com>2016-05-16 09:12:34 +0000
committerngkaho1234 <ngkaho1234@gmail.com>2016-05-16 13:50:54 +0000
commit6a6833fd4b9b2067e7baf0520fc792d230a9ef2c (patch)
tree1d09db38337e0db84a76b4c59d6f0099753fe3a5
parent06382010385758c11ab9e643751c88c7e969ca34 (diff)
ext4_xattr: type changes
- struct ext4_xattr_ref::inode_size_rem's type is changed from int32_t to size_t - struct ext4_xattr_ref::block_size_rem's type is changed from int32_t to size_t
-rw-r--r--include/ext4_xattr.h4
-rw-r--r--src/ext4_xattr.c57
2 files changed, 35 insertions, 26 deletions
diff --git a/include/ext4_xattr.h b/include/ext4_xattr.h
index a5cd814..3cd1bcd 100644
--- a/include/ext4_xattr.h
+++ b/include/ext4_xattr.h
@@ -67,8 +67,8 @@ struct ext4_xattr_ref {
struct ext4_inode_ref *inode_ref;
bool dirty;
size_t ea_size;
- int32_t block_size_rem;
- int32_t inode_size_rem;
+ size_t block_size_rem;
+ size_t inode_size_rem;
struct ext4_fs *fs;
void *iter_arg;
diff --git a/src/ext4_xattr.c b/src/ext4_xattr.c
index 013879e..240ac43 100644
--- a/src/ext4_xattr.c
+++ b/src/ext4_xattr.c
@@ -476,12 +476,12 @@ ext4_xattr_insert_item(struct ext4_xattr_ref *xattr_ref, uint8_t name_index,
return NULL;
}
item->in_inode = true;
- if (xattr_ref->inode_size_rem -
- (int32_t)EXT4_XATTR_SIZE(data_size) -
- (int32_t)EXT4_XATTR_LEN(item->name_len) < 0) {
- if (xattr_ref->block_size_rem -
- (int32_t)EXT4_XATTR_SIZE(data_size) -
- (int32_t)EXT4_XATTR_LEN(item->name_len) < 0) {
+ if (xattr_ref->inode_size_rem <
+ EXT4_XATTR_SIZE(data_size) +
+ EXT4_XATTR_LEN(item->name_len)) {
+ if (xattr_ref->block_size_rem <
+ EXT4_XATTR_SIZE(data_size) +
+ EXT4_XATTR_LEN(item->name_len)) {
if (err)
*err = ENOSPC;
@@ -586,22 +586,22 @@ static int ext4_xattr_resize_item(struct ext4_xattr_ref *xattr_ref,
*/
if (item->in_inode) {
if (xattr_ref->inode_size_rem +
- (int32_t)EXT4_XATTR_SIZE(old_data_size) -
- (int32_t)EXT4_XATTR_SIZE(new_data_size) < 0) {
- if (xattr_ref->block_size_rem -
- (int32_t)EXT4_XATTR_SIZE(new_data_size) -
- (int32_t)EXT4_XATTR_LEN(item->name_len) < 0)
+ EXT4_XATTR_SIZE(old_data_size) <
+ EXT4_XATTR_SIZE(new_data_size)) {
+ if (xattr_ref->block_size_rem <
+ EXT4_XATTR_SIZE(new_data_size) +
+ EXT4_XATTR_LEN(item->name_len))
return ENOSPC;
to_block = true;
}
} else {
if (xattr_ref->block_size_rem +
- (int32_t)EXT4_XATTR_SIZE(old_data_size) -
- (int32_t)EXT4_XATTR_SIZE(new_data_size) < 0) {
- if (xattr_ref->inode_size_rem -
- (int32_t)EXT4_XATTR_SIZE(new_data_size) -
- (int32_t)EXT4_XATTR_LEN(item->name_len) < 0)
+ EXT4_XATTR_SIZE(old_data_size) <
+ EXT4_XATTR_SIZE(new_data_size)) {
+ if (xattr_ref->inode_size_rem <
+ EXT4_XATTR_SIZE(new_data_size) +
+ EXT4_XATTR_LEN(item->name_len))
return ENOSPC;
to_inode = true;
@@ -663,12 +663,16 @@ static void ext4_xattr_purge_items(struct ext4_xattr_ref *xattr_ref)
ext4_xattr_item_free(item);
}
xattr_ref->ea_size = 0;
- xattr_ref->inode_size_rem = ext4_xattr_inode_space(xattr_ref) -
- sizeof(struct ext4_xattr_ibody_header);
- if (xattr_ref->inode_size_rem < 0)
+ if (ext4_xattr_inode_space(xattr_ref) <
+ sizeof(struct ext4_xattr_ibody_header))
xattr_ref->inode_size_rem = 0;
+ else
+ xattr_ref->inode_size_rem =
+ ext4_xattr_inode_space(xattr_ref) -
+ sizeof(struct ext4_xattr_ibody_header);
- xattr_ref->block_size_rem = ext4_xattr_block_space(xattr_ref) -
+ xattr_ref->block_size_rem =
+ ext4_xattr_block_space(xattr_ref) -
sizeof(struct ext4_xattr_header);
}
@@ -996,13 +1000,18 @@ int ext4_fs_get_xattr_ref(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref,
ref->inode_ref = inode_ref;
ref->fs = fs;
- ref->inode_size_rem = ext4_xattr_inode_space(ref) -
- sizeof(struct ext4_xattr_ibody_header);
- if (ref->inode_size_rem < 0)
+ if (ext4_xattr_inode_space(ref) <
+ sizeof(struct ext4_xattr_ibody_header))
ref->inode_size_rem = 0;
+ else
+ ref->inode_size_rem =
+ ext4_xattr_inode_space(ref) -
+ sizeof(struct ext4_xattr_ibody_header);
- ref->block_size_rem = ext4_xattr_block_space(ref) -
+ ref->block_size_rem =
+ ext4_xattr_block_space(ref) -
sizeof(struct ext4_xattr_header);
+
rc = ext4_xattr_fetch(ref);
if (rc != EOK) {
ext4_xattr_purge_items(ref);