ref: 6a6833fd4b9b2067e7baf0520fc792d230a9ef2c
parent: 06382010385758c11ab9e643751c88c7e969ca34
author: ngkaho1234 <[email protected]>
date: Mon May 16 05:12:34 EDT 2016
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
--- a/include/ext4_xattr.h
+++ b/include/ext4_xattr.h
@@ -67,8 +67,8 @@
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;
--- a/src/ext4_xattr.c
+++ b/src/ext4_xattr.c
@@ -476,12 +476,12 @@
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,11 +586,11 @@
*/
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;
@@ -597,11 +597,11 @@
}
} 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 @@
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 @@
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);