Changeset b7fd2a0 in mainline for uspace/lib/ext4/src/directory.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/src/directory.c

    r36f0738 rb7fd2a0  
    169169}
    170170
    171 static int ext4_directory_iterator_seek(ext4_directory_iterator_t *, aoff64_t);
    172 static int ext4_directory_iterator_set(ext4_directory_iterator_t *, uint32_t);
     171static errno_t ext4_directory_iterator_seek(ext4_directory_iterator_t *, aoff64_t);
     172static errno_t ext4_directory_iterator_set(ext4_directory_iterator_t *, uint32_t);
    173173
    174174/** Initialize directory iterator.
     
    183183 *
    184184 */
    185 int ext4_directory_iterator_init(ext4_directory_iterator_t *it,
     185errno_t ext4_directory_iterator_init(ext4_directory_iterator_t *it,
    186186    ext4_inode_ref_t *inode_ref, aoff64_t pos)
    187187{
     
    201201 *
    202202 */
    203 int ext4_directory_iterator_next(ext4_directory_iterator_t *it)
     203errno_t ext4_directory_iterator_next(ext4_directory_iterator_t *it)
    204204{
    205205        assert(it->current != NULL);
     
    220220 *
    221221 */
    222 int ext4_directory_iterator_seek(ext4_directory_iterator_t *it, aoff64_t pos)
     222errno_t ext4_directory_iterator_seek(ext4_directory_iterator_t *it, aoff64_t pos)
    223223{
    224224        uint64_t size = ext4_inode_get_size(it->inode_ref->fs->superblock,
     
    231231        if (pos >= size) {
    232232                if (it->current_block) {
    233                         int rc = block_put(it->current_block);
     233                        errno_t rc = block_put(it->current_block);
    234234                        it->current_block = NULL;
    235235                       
     
    255255            (current_block_idx != next_block_idx)) {
    256256                if (it->current_block) {
    257                         int rc = block_put(it->current_block);
     257                        errno_t rc = block_put(it->current_block);
    258258                        it->current_block = NULL;
    259259                       
     
    263263               
    264264                uint32_t next_block_phys_idx;
    265                 int rc = ext4_filesystem_get_inode_data_block_index(it->inode_ref,
     265                errno_t rc = ext4_filesystem_get_inode_data_block_index(it->inode_ref,
    266266                    next_block_idx, &next_block_phys_idx);
    267267                if (rc != EOK)
     
    289289 *
    290290 */
    291 static int ext4_directory_iterator_set(ext4_directory_iterator_t *it,
     291static errno_t ext4_directory_iterator_set(ext4_directory_iterator_t *it,
    292292    uint32_t block_size)
    293293{
     
    331331 *
    332332 */
    333 int ext4_directory_iterator_fini(ext4_directory_iterator_t *it)
     333errno_t ext4_directory_iterator_fini(ext4_directory_iterator_t *it)
    334334{
    335335        it->inode_ref = NULL;
     
    386386 *
    387387 */
    388 int ext4_directory_add_entry(ext4_inode_ref_t *parent, const char *name,
     388errno_t ext4_directory_add_entry(ext4_inode_ref_t *parent, const char *name,
    389389    ext4_inode_ref_t *child)
    390390{
     
    395395            EXT4_FEATURE_COMPAT_DIR_INDEX)) &&
    396396            (ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX))) {
    397                 int rc = ext4_directory_dx_add_entry(parent, child, name);
     397                errno_t rc = ext4_directory_dx_add_entry(parent, child, name);
    398398
    399399                /* Check if index is not corrupted */
     
    419419        bool success = false;
    420420        for (iblock = 0; iblock < total_blocks; ++iblock) {
    421                 int rc = ext4_filesystem_get_inode_data_block_index(parent,
     421                errno_t rc = ext4_filesystem_get_inode_data_block_index(parent,
    422422                    iblock, &fblock);
    423423                if (rc != EOK)
     
    447447        iblock = 0;
    448448        fblock = 0;
    449         int rc = ext4_filesystem_append_inode_block(parent, &fblock, &iblock);
     449        errno_t rc = ext4_filesystem_append_inode_block(parent, &fblock, &iblock);
    450450        if (rc != EOK)
    451451                return rc;
     
    479479 *
    480480 */
    481 int ext4_directory_find_entry(ext4_directory_search_result_t *result,
     481errno_t ext4_directory_find_entry(ext4_directory_search_result_t *result,
    482482    ext4_inode_ref_t *parent, const char *name)
    483483{
     
    490490            EXT4_FEATURE_COMPAT_DIR_INDEX)) &&
    491491            (ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX))) {
    492                 int rc = ext4_directory_dx_find_entry(result, parent, name_len,
     492                errno_t rc = ext4_directory_dx_find_entry(result, parent, name_len,
    493493                    name);
    494494               
     
    517517        for (iblock = 0; iblock < total_blocks; ++iblock) {
    518518                /* Load block address */
    519                 int rc = ext4_filesystem_get_inode_data_block_index(parent, iblock,
     519                errno_t rc = ext4_filesystem_get_inode_data_block_index(parent, iblock,
    520520                    &fblock);
    521521                if (rc != EOK)
     
    561561 *
    562562 */
    563 int ext4_directory_remove_entry(ext4_inode_ref_t *parent, const char *name)
     563errno_t ext4_directory_remove_entry(ext4_inode_ref_t *parent, const char *name)
    564564{
    565565        /* Check if removing from directory */
     
    570570        /* Try to find entry */
    571571        ext4_directory_search_result_t result;
    572         int rc = ext4_directory_find_entry(&result, parent, name);
     572        errno_t rc = ext4_directory_find_entry(&result, parent, name);
    573573        if (rc != EOK)
    574574                return rc;
     
    626626 *
    627627 */
    628 int ext4_directory_try_insert_entry(ext4_superblock_t *sb,
     628errno_t ext4_directory_try_insert_entry(ext4_superblock_t *sb,
    629629    block_t *target_block, ext4_inode_ref_t *child, const char *name,
    630630    uint32_t name_len)
     
    705705 *
    706706 */
    707 int ext4_directory_find_in_block(block_t *block, ext4_superblock_t *sb,
     707errno_t ext4_directory_find_in_block(block_t *block, ext4_superblock_t *sb,
    708708    size_t name_len, const char *name, ext4_directory_entry_ll_t **res_entry)
    709709{
     
    756756 *
    757757 */
    758 int ext4_directory_destroy_result(ext4_directory_search_result_t *result)
     758errno_t ext4_directory_destroy_result(ext4_directory_search_result_t *result)
    759759{
    760760        if (result->block)
Note: See TracChangeset for help on using the changeset viewer.