Fix a compile issue with big endian config & some small issues fixes
[lwext4.git] / src / ext4_balloc.c
index 2980e2686c030c5fbbdedfd4fb5c8cae7e37ae20..89455544f657e1c642aead88a912639358ba4d95 100644 (file)
  * @brief Physical block allocator.
  */
 
-#include "ext4_config.h"
-#include "ext4_balloc.h"
-#include "ext4_super.h"
-#include "ext4_crc32.h"
-#include "ext4_block_group.h"
-#include "ext4_fs.h"
-#include "ext4_bitmap.h"
-#include "ext4_inode.h"
+#include <ext4_config.h>
+#include <ext4_types.h>
+#include <ext4_misc.h>
+#include <ext4_errno.h>
+#include <ext4_debug.h>
+
+#include <ext4_trans.h>
+#include <ext4_balloc.h>
+#include <ext4_super.h>
+#include <ext4_crc32.h>
+#include <ext4_block_group.h>
+#include <ext4_fs.h>
+#include <ext4_bitmap.h>
+#include <ext4_inode.h>
 
 /**@brief Compute number of block group from block address.
  * @param sb superblock pointer.
@@ -219,13 +225,17 @@ int ext4_balloc_free_block(struct ext4_inode_ref *inode_ref, ext4_fsblk_t baddr)
        }
        ext4_bcache_invalidate_lba(fs->bdev->bc, baddr, 1);
        /* Release block group reference */
-       return ext4_fs_put_block_group_ref(&bg_ref);
+       rc = ext4_fs_put_block_group_ref(&bg_ref);
+
+       return rc;
 }
 
 int ext4_balloc_free_blocks(struct ext4_inode_ref *inode_ref,
                            ext4_fsblk_t first, uint32_t count)
 {
        int rc = EOK;
+       uint32_t blk_cnt = count;
+       ext4_fsblk_t start_block = first;
        struct ext4_fs *fs = inode_ref->fs;
        struct ext4_sblock *sb = &fs->sb;
 
@@ -325,16 +335,17 @@ int ext4_balloc_free_blocks(struct ext4_inode_ref *inode_ref,
        }
 
        uint32_t i;
-       for (i = 0;i < count;i++) {
-               rc = ext4_trans_try_revoke_block(fs->bdev, first + i);
+       for (i = 0;i < blk_cnt;i++) {
+               rc = ext4_trans_try_revoke_block(fs->bdev, start_block + i);
                if (rc != EOK)
                        return rc;
 
        }
 
-       ext4_bcache_invalidate_lba(fs->bdev->bc, first, count);
+       ext4_bcache_invalidate_lba(fs->bdev->bc, start_block, blk_cnt);
        /*All blocks should be released*/
        ext4_assert(count == 0);
+
        return rc;
 }