Changeset b7fd2a0 in mainline for uspace/drv/block/ddisk/ddisk.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (7 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/drv/block/ddisk/ddisk.c

    r36f0738 rb7fd2a0  
    5656#define DDISK_CMD_IRQ_DEASSERT  0x4
    5757
    58 static int ddisk_dev_add(ddf_dev_t *);
    59 static int ddisk_dev_remove(ddf_dev_t *);
    60 static int ddisk_dev_gone(ddf_dev_t *);
    61 static int ddisk_fun_online(ddf_fun_t *);
    62 static int ddisk_fun_offline(ddf_fun_t *);
     58static errno_t ddisk_dev_add(ddf_dev_t *);
     59static errno_t ddisk_dev_remove(ddf_dev_t *);
     60static errno_t ddisk_dev_gone(ddf_dev_t *);
     61static errno_t ddisk_fun_online(ddf_fun_t *);
     62static errno_t ddisk_fun_offline(ddf_fun_t *);
    6363
    6464static void ddisk_bd_connection(ipc_callid_t, ipc_call_t *, void *);
     
    117117} ddisk_t;
    118118
    119 static int ddisk_bd_open(bd_srvs_t *, bd_srv_t *);
    120 static int ddisk_bd_close(bd_srv_t *);
    121 static int ddisk_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
    122 static int ddisk_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *,
     119static errno_t ddisk_bd_open(bd_srvs_t *, bd_srv_t *);
     120static errno_t ddisk_bd_close(bd_srv_t *);
     121static errno_t ddisk_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     122static errno_t ddisk_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *,
    123123    size_t);
    124 static int ddisk_bd_get_block_size(bd_srv_t *, size_t *);
    125 static int ddisk_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
     124static errno_t ddisk_bd_get_block_size(bd_srv_t *, size_t *);
     125static errno_t ddisk_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
    126126
    127127bd_ops_t ddisk_bd_ops = {
     
    188188}
    189189
    190 int ddisk_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    191 {
    192         return EOK;
    193 }
    194 
    195 int ddisk_bd_close(bd_srv_t *bd)
     190errno_t ddisk_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
     191{
     192        return EOK;
     193}
     194
     195errno_t ddisk_bd_close(bd_srv_t *bd)
    196196{
    197197        return EOK;
     
    199199
    200200static
    201 int ddisk_rw_block(ddisk_t *ddisk, bool read, aoff64_t ba, void *buf)
     201errno_t ddisk_rw_block(ddisk_t *ddisk, bool read, aoff64_t ba, void *buf)
    202202{
    203203        fibril_mutex_lock(&ddisk->lock);
     
    236236
    237237static
    238 int ddisk_bd_rw_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt, void *buf,
     238errno_t ddisk_bd_rw_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt, void *buf,
    239239    size_t size, bool is_read)
    240240{
    241241        ddisk_t *ddisk = (ddisk_t *) bd->srvs->sarg;
    242242        aoff64_t i;
    243         int rc;
     243        errno_t rc;
    244244
    245245        if (size < cnt * DDISK_BLOCK_SIZE)
     
    256256}
    257257
    258 int ddisk_bd_read_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt, void *buf,
     258errno_t ddisk_bd_read_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt, void *buf,
    259259    size_t size)
    260260{
     
    262262}
    263263
    264 int ddisk_bd_write_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
     264errno_t ddisk_bd_write_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
    265265    const void *buf, size_t size)
    266266{
     
    268268}
    269269
    270 int ddisk_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
     270errno_t ddisk_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
    271271{
    272272        *rsize = DDISK_BLOCK_SIZE;
     
    274274}
    275275
    276 int ddisk_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
     276errno_t ddisk_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
    277277{
    278278        ddisk_t *ddisk = (ddisk_t *) bd->srvs->sarg;
     
    282282}
    283283
    284 static int ddisk_get_res(ddf_dev_t *dev, ddisk_res_t *ddisk_res)
     284static errno_t ddisk_get_res(ddf_dev_t *dev, ddisk_res_t *ddisk_res)
    285285{
    286286        async_sess_t *parent_sess;
    287287        hw_res_list_parsed_t hw_res;
    288         int rc;
     288        errno_t rc;
    289289
    290290        parent_sess = ddf_dev_parent_sess_get(dev);
     
    317317}
    318318
    319 static int ddisk_fun_create(ddisk_t *ddisk)
    320 {
    321         int rc;
     319static errno_t ddisk_fun_create(ddisk_t *ddisk)
     320{
     321        errno_t rc;
    322322        ddf_fun_t *fun = NULL;
    323323
     
    350350}
    351351
    352 static int ddisk_fun_remove(ddisk_t *ddisk)
    353 {
    354         int rc;
     352static errno_t ddisk_fun_remove(ddisk_t *ddisk)
     353{
     354        errno_t rc;
    355355
    356356        if (ddisk->fun == NULL)
     
    381381}
    382382
    383 static int ddisk_fun_unbind(ddisk_t *ddisk)
    384 {
    385         int rc;
     383static errno_t ddisk_fun_unbind(ddisk_t *ddisk)
     384{
     385        errno_t rc;
    386386
    387387        if (ddisk->fun == NULL)
     
    410410 * @return     EOK on success or an error code.
    411411 */
    412 static int ddisk_dev_add(ddf_dev_t *dev)
     412static errno_t ddisk_dev_add(ddf_dev_t *dev)
    413413{
    414414        ddisk_t *ddisk;
    415415        ddisk_res_t res;
    416         int rc;
     416        errno_t rc;
    417417
    418418        /*
     
    530530
    531531
    532 static int ddisk_dev_remove_common(ddisk_t *ddisk, bool surprise)
    533 {
    534         int rc;
     532static errno_t ddisk_dev_remove_common(ddisk_t *ddisk, bool surprise)
     533{
     534        errno_t rc;
    535535
    536536        if (!surprise)
     
    558558}
    559559
    560 static int ddisk_dev_remove(ddf_dev_t *dev)
     560static errno_t ddisk_dev_remove(ddf_dev_t *dev)
    561561{
    562562        ddisk_t *ddisk = (ddisk_t *) ddf_dev_data_get(dev);
     
    566566}
    567567
    568 static int ddisk_dev_gone(ddf_dev_t *dev)
     568static errno_t ddisk_dev_gone(ddf_dev_t *dev)
    569569{
    570570        ddisk_t *ddisk = (ddisk_t *) ddf_dev_data_get(dev);
     
    574574}
    575575
    576 static int ddisk_fun_online(ddf_fun_t *fun)
     576static errno_t ddisk_fun_online(ddf_fun_t *fun)
    577577{
    578578        ddf_msg(LVL_DEBUG, "ddisk_fun_online()");
     
    580580}
    581581
    582 static int ddisk_fun_offline(ddf_fun_t *fun)
     582static errno_t ddisk_fun_offline(ddf_fun_t *fun)
    583583{
    584584        ddf_msg(LVL_DEBUG, "ddisk_fun_offline()");
Note: See TracChangeset for help on using the changeset viewer.