Changeset 532f53d in mainline


Ignore:
Timestamp:
2013-11-20T21:47:41Z (10 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e5a1ace3
Parents:
2764497
Message:

ext4: return the error code to the caller in case something fails.

Location:
uspace
Files:
3 edited

Legend:

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

    r2764497 r532f53d  
    371371    uint32_t *fblock)
    372372{
     373        int rc;
    373374        /* Compute bound defined by i-node size */
    374375        uint64_t inode_size =
     
    400401                uint64_t child = ext4_extent_index_get_leaf(index);
    401402               
    402                 if (block != NULL)
    403                         block_put(block);
    404                
    405                 int rc = block_get(&block, inode_ref->fs->device, child,
     403                if (block != NULL) {
     404                        rc = block_put(block);
     405                        if (rc != EOK)
     406                                return rc;
     407                }
     408               
     409                rc = block_get(&block, inode_ref->fs->device, child,
    406410                    BLOCK_FLAGS_NONE);
    407411                if (rc != EOK)
     
    429433        /* Cleanup */
    430434        if (block != NULL)
    431                 block_put(block);
    432        
    433         return EOK;
     435                rc = block_put(block);
     436       
     437        return rc;
    434438}
    435439
     
    505509       
    506510cleanup:
     511        ;
     512
     513        int rc2 = EOK;
     514
    507515        /*
    508516         * Put loaded blocks
     
    510518         */
    511519        for (uint16_t i = 1; i < tmp_path->depth; ++i) {
    512                 if (tmp_path[i].block)
    513                         block_put(tmp_path[i].block);
     520                if (tmp_path[i].block) {
     521                        rc2 = block_put(tmp_path[i].block);
     522                        if (rc == EOK && rc2 != EOK)
     523                                rc = rc2;
     524                }
    514525        }
    515526       
     
    594605                return rc;
    595606       
    596         ext4_balloc_free_block(inode_ref, fblock);
    597        
    598         return EOK;
     607        return ext4_balloc_free_block(inode_ref, fblock);
    599608}
    600609
     
    721730       
    722731cleanup:
     732        ;
     733
     734        int rc2 = EOK;
     735
    723736        /*
    724737         * Put loaded blocks
     
    726739         */
    727740        for (uint16_t i = 1; i <= path->depth; ++i) {
    728                 if (path[i].block)
    729                         block_put(path[i].block);
     741                if (path[i].block) {
     742                        rc2 = block_put(path[i].block);
     743                        if (rc == EOK && rc2 != EOK)
     744                                rc = rc2;
     745                }
    730746        }
    731747       
     
    10611077       
    10621078finish:
     1079        ;
     1080
     1081        int rc2 = EOK;
     1082
    10631083        /* Set return values */
    10641084        *iblock = new_block_idx;
     
    10701090         */
    10711091        for (uint16_t i = 1; i <= path->depth; ++i) {
    1072                 if (path[i].block)
    1073                         block_put(path[i].block);
     1092                if (path[i].block) {
     1093                        rc2 = block_put(path[i].block);
     1094                        if (rc == EOK && rc2 != EOK)
     1095                                rc = rc2;
     1096                }
    10741097        }
    10751098       
  • uspace/lib/ext4/libext4_filesystem.c

    r2764497 r532f53d  
    797797                }
    798798               
    799                 block_put(block);
     799                rc = block_put(block);
     800                if (rc != EOK)
     801                        return rc;
     802
    800803                rc = ext4_balloc_free_block(inode_ref, fblock);
    801804                if (rc != EOK)
     
    841844                                }
    842845                               
    843                                 block_put(subblock);
     846                                rc = block_put(subblock);
     847                                if (rc != EOK)
     848                                        return rc;
    844849                        }
    845850                       
     
    851856                }
    852857               
    853                 block_put(block);
     858                rc = block_put(block);
     859                if (rc != EOK)
     860                        return rc;
     861
    854862                rc = ext4_balloc_free_block(inode_ref, fblock);
    855863                if (rc != EOK)
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    r2764497 r532f53d  
    259259        rc = ext4fs_node_get_core(rfn, eparent->instance, inode);
    260260        if (rc != EOK)
    261                 return rc;
    262        
     261                goto exit;
     262
     263exit:
     264        ;
     265
    263266        /* Destroy search result structure */
    264         return ext4_directory_destroy_result(&result);
     267        int const rc2 = ext4_directory_destroy_result(&result);
     268        return rc == EOK ? rc2 : rc;
    265269}
    266270
     
    10021006        *lnkcnt = 1;
    10031007       
    1004         ext4fs_node_put(root_node);
    1005        
    1006         return EOK;
     1008        return ext4fs_node_put(root_node);
    10071009}
    10081010
     
    10931095        }
    10941096       
    1095         ext4_filesystem_put_inode_ref(inode_ref);
    1096        
    1097         return rc;
     1097        int const rc2 = ext4_filesystem_put_inode_ref(inode_ref);
     1098       
     1099        return rc == EOK ? rc2 : rc;
    10981100}
    10991101
     
    12681270                memset(buffer, 0, bytes);
    12691271               
    1270                 async_data_read_finalize(callid, buffer, bytes);
     1272                rc = async_data_read_finalize(callid, buffer, bytes);
    12711273                *rbytes = bytes;
    12721274               
    12731275                free(buffer);
    1274                 return EOK;
     1276                return rc;
    12751277        }
    12761278       
     
    12841286       
    12851287        assert(offset_in_block + bytes <= block_size);
    1286         async_data_read_finalize(callid, block->data + offset_in_block, bytes);
     1288        rc = async_data_read_finalize(callid, block->data + offset_in_block, bytes);
     1289        if (rc != EOK) {
     1290                block_put(block);
     1291                return rc;
     1292        }
    12871293       
    12881294        rc = block_put(block);
     
    13161322        size_t len;
    13171323        if (!async_data_write_receive(&callid, &len)) {
    1318                 ext4fs_node_put(fn);
    1319                 async_answer_0(callid, EINVAL);
    1320                 return EINVAL;
     1324                rc = EINVAL;
     1325                async_answer_0(callid, rc);
     1326                goto exit;
    13211327        }
    13221328       
     
    13411347            &fblock);
    13421348        if (rc != EOK) {
    1343                 ext4fs_node_put(fn);
    13441349                async_answer_0(callid, rc);
    1345                 return rc;
     1350                goto exit;
    13461351        }
    13471352       
     
    13591364                                    &fblock, true);
    13601365                                if (rc != EOK) {
    1361                                         ext4fs_node_put(fn);
    13621366                                        async_answer_0(callid, rc);
    1363                                         return rc;
     1367                                        goto exit;
    13641368                                }
    13651369                        }
     
    13681372                            &fblock, false);
    13691373                        if (rc != EOK) {
    1370                                 ext4fs_node_put(fn);
    13711374                                async_answer_0(callid, rc);
    1372                                 return rc;
     1375                                goto exit;
    13731376                        }
    13741377                } else {
    13751378                        rc = ext4_balloc_alloc_block(inode_ref, &fblock);
    13761379                        if (rc != EOK) {
    1377                                 ext4fs_node_put(fn);
    13781380                                async_answer_0(callid, rc);
    1379                                 return rc;
     1381                                goto exit;
    13801382                        }
    13811383                       
     
    13841386                        if (rc != EOK) {
    13851387                                ext4_balloc_free_block(inode_ref, fblock);
    1386                                 ext4fs_node_put(fn);
    13871388                                async_answer_0(callid, rc);
    1388                                 return rc;
     1389                                goto exit;
    13891390                        }
    13901391                }
     
    13981399        rc = block_get(&write_block, service_id, fblock, flags);
    13991400        if (rc != EOK) {
    1400                 ext4fs_node_put(fn);
    14011401                async_answer_0(callid, rc);
    1402                 return rc;
     1402                goto exit;
    14031403        }
    14041404       
    14051405        if (flags == BLOCK_FLAGS_NOREAD)
    14061406                memset(write_block->data, 0, block_size);
    1407        
     1407
    14081408        rc = async_data_write_finalize(callid, write_block->data +
    14091409            (pos % block_size), bytes);
    1410         if (rc != EOK) {
    1411                 ext4fs_node_put(fn);
    1412                 return rc;
    1413         }
    1414        
     1410        if (rc != EOK)
     1411                goto exit;
     1412
    14151413        write_block->dirty = true;
    14161414       
    14171415        rc = block_put(write_block);
    1418         if (rc != EOK) {
    1419                 ext4fs_node_put(fn);
    1420                 return rc;
    1421         }
    1422        
     1416        if (rc != EOK)
     1417                goto exit;
     1418
    14231419        /* Do some counting */
    14241420        uint32_t old_inode_size = ext4_inode_get_size(fs->superblock,
     
    14281424                inode_ref->dirty = true;
    14291425        }
    1430        
     1426
    14311427        *nsize = ext4_inode_get_size(fs->superblock, inode_ref->inode);
    14321428        *wbytes = bytes;
    1433        
    1434         return ext4fs_node_put(fn);
     1429
     1430exit:
     1431        ;
     1432
     1433        int const rc2 = ext4fs_node_put(fn);
     1434        return rc == EOK ? rc2 : rc;
    14351435}
    14361436
     
    14581458       
    14591459        rc = ext4_filesystem_truncate_inode(inode_ref, new_size);
    1460         ext4fs_node_put(fn);
    1461        
    1462         return rc;
     1460        int const rc2 = ext4fs_node_put(fn);
     1461       
     1462        return rc == EOK ? rc2 : rc;
    14631463}
    14641464
Note: See TracChangeset for help on using the changeset viewer.