Changeset d9bbe45 in mainline for uspace/lib/ext4/libext4_inode.c


Ignore:
Timestamp:
2012-01-22T13:22:56Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fcae007
Parents:
b7e0260
Message:

Refafctorization - principle of locality in variables declaration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_inode.c

    rb7e0260 rd9bbe45  
    160160uint64_t ext4_inode_get_blocks_count(ext4_superblock_t *sb, ext4_inode_t *inode)
    161161{
    162         uint64_t count;
    163 
    164162        if (ext4_superblock_has_feature_read_only(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
    165163
    166164                /* 48-bit field */
    167                 count = ((uint64_t)uint16_t_le2host(inode->osd2.linux2.blocks_high)) << 32 |
     165                uint64_t count = ((uint64_t)uint16_t_le2host(inode->osd2.linux2.blocks_high)) << 32 |
    168166                                uint32_t_le2host(inode->blocks_count_lo);
    169167
     
    283281uint32_t ext4_inode_get_extent_block(ext4_inode_t *inode, uint64_t idx, service_id_t service_id)
    284282{
     283        int rc;
     284
     285        block_t* block = NULL;
     286
    285287        ext4_extent_header_t *header = ext4_inode_get_extent_header(inode);
    286         ext4_extent_t *extent;
    287         ext4_extent_index_t *extent_index;
    288 
    289         uint32_t first_block;
    290         uint16_t block_count;
    291         uint64_t phys_block = 0;
    292         uint64_t child;
    293 
    294         int rc;
    295         block_t* block = NULL;
    296 
    297288        while (ext4_extent_header_get_depth(header) != 0) {
    298289
    299                 extent_index = EXT4_EXTENT_FIRST_INDEX(header);
     290                ext4_extent_index_t *extent_index = EXT4_EXTENT_FIRST_INDEX(header);
    300291
    301292                for (uint16_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i) {
    302                         if(idx >= ext4_extent_index_get_first_block(extent_index)) {
    303 
    304                                 child = ext4_extent_index_get_leaf(extent_index);
     293                        if (idx >= ext4_extent_index_get_first_block(extent_index)) {
     294
     295                                uint64_t child = ext4_extent_index_get_leaf(extent_index);
    305296
    306297                                if (block != NULL) {
     
    319310        }
    320311
    321         extent = EXT4_EXTENT_FIRST(header);
     312        ext4_extent_t *extent = EXT4_EXTENT_FIRST(header);
     313        uint64_t phys_block = 0;
    322314
    323315        for (uint16_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i) {
    324316
    325                 first_block = ext4_extent_get_first_block(extent);
    326                 block_count = ext4_extent_get_block_count(extent);
     317                uint32_t first_block = ext4_extent_get_first_block(extent);
     318                uint16_t block_count = ext4_extent_get_block_count(extent);
    327319
    328320                if ((idx >= first_block) && (idx < first_block + block_count)) {
    329                         phys_block = ext4_extent_get_start(extent) + idx;
    330                         phys_block -= ext4_extent_get_first_block(extent);
    331 
    332                         // Memory leak prevention
    333                         if (block != NULL) {
    334                                 block_put(block);
    335                         }
    336                         return phys_block;
     321                         phys_block = ext4_extent_get_start(extent) + idx;
     322                         phys_block -= ext4_extent_get_first_block(extent);
     323
     324                         // Memory leak prevention
     325                         if (block != NULL) {
     326                                 block_put(block);
     327                         }
     328                         return phys_block;
    337329                }
    338330                // Go to the next extent
Note: See TracChangeset for help on using the changeset viewer.