Changeset 6f41312 in mainline


Ignore:
Timestamp:
2012-04-08T09:09:57Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
95947d24
Parents:
1196df6
Message:

error handling TODOs done

File:
1 edited

Legend:

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

    r1196df6 r6f41312  
    302302                rc = block_get(&block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NONE);
    303303                if (rc != EOK) {
    304                         // TODO cleanup
    305                         EXT4FS_DBG("ERRRR");
    306                         return rc;
     304                        goto cleanup;
    307305                }
    308306
     
    325323
    326324        return EOK;
     325
     326cleanup:
     327        // Put loaded blocks
     328        // From 1 -> 0 is a block with inode data
     329        for (uint16_t i = 1; i < tmp_path->depth; ++i) {
     330                if (tmp_path[i].block) {
     331                        block_put(tmp_path[i].block);
     332                }
     333        }
     334
     335        // Destroy temporary data structure
     336        free(tmp_path);
     337
     338        return rc;
     339
    327340}
    328341
     
    400413                uint32_t iblock_from)
    401414{
    402         int rc;
     415        int rc = EOK;
    403416
    404417        // Find the first extent to modify
     
    429442        rc = ext4_balloc_free_blocks(inode_ref, first_fblock, delete_count);
    430443        if (rc != EOK) {
    431                 // TODO goto cleanup
    432                 EXT4FS_DBG("ERROR");
    433                 return rc;
     444                goto cleanup;
    434445        }
    435446
     
    454465                rc = ext4_balloc_free_blocks(inode_ref, first_fblock, delete_count);
    455466                if (rc != EOK) {
    456                         // TODO goto cleanup
    457                         EXT4FS_DBG("ERROR");
    458                         return rc;
     467                        goto cleanup;
    459468                }
    460469
     
    472481                rc = ext4_balloc_free_block(inode_ref, path_ptr->block->lba);
    473482                if (rc != EOK) {
    474                         EXT4FS_DBG("ERROR");
    475                         // TODO goto cleanup
    476                         return rc;
     483                        goto cleanup;
    477484                }
    478485                check_tree = true;
     
    497504                        rc = ext4_extent_release_branch(inode_ref, index);
    498505                        if (rc != EOK) {
    499                                 EXT4FS_DBG("ERR");
    500                                 // TODO goto cleanup
    501                                 return rc;
     506                                goto cleanup;
    502507                        }
    503508                        ++index;
     
    511516                        rc = ext4_balloc_free_block(inode_ref, path_ptr->block->lba);
    512517                        if (rc != EOK) {
    513                                 EXT4FS_DBG("ERROR");
    514                                 // TODO goto cleanup
    515                                 return rc;
     518                                goto cleanup;
    516519                        }
    517520                        check_tree = true;
     
    524527
    525528
    526         // Finish
    527         uint16_t depth = path->depth;
    528 
     529cleanup:
    529530        // Put loaded blocks
    530531        // From 1 -> 0 is a block with inode data
    531         for (uint16_t i = 1; i < depth; ++i) {
     532        for (uint16_t i = 1; i < path->depth; ++i) {
    532533                if (path[i].block) {
    533534                        block_put(path[i].block);
     
    538539        free(path);
    539540
    540         return EOK;
     541        return rc;
    541542}
    542543
     
    544545                uint32_t *iblock, uint32_t *fblock)
    545546{
    546         int rc;
     547        int rc = EOK;
    547548
    548549        ext4_superblock_t *sb = inode_ref->fs->superblock;
     
    569570        rc = ext4_extent_find_extent(inode_ref, new_block_idx, &path);
    570571        if (rc != EOK) {
    571                 EXT4FS_DBG("find extent ERROR");
    572572                return rc;
    573573        }
     
    590590                rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
    591591                if (rc != EOK) {
    592                         EXT4FS_DBG("ERRO in balloc");
    593                         return rc;
     592                        goto finish;
    594593                }
    595594
     
    626625        free(path);
    627626
    628         return EOK;
     627        return rc;
    629628}
    630629
Note: See TracChangeset for help on using the changeset viewer.