Changeset b7fd2a0 in mainline for uspace/srv/bd/rd/rd.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/srv/bd/rd/rd.c

    r36f0738 rb7fd2a0  
    6767static const size_t block_size = 512;
    6868
    69 static int rd_open(bd_srvs_t *, bd_srv_t *);
    70 static int rd_close(bd_srv_t *);
    71 static int rd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
    72 static int rd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
    73 static int rd_get_block_size(bd_srv_t *, size_t *);
    74 static int rd_get_num_blocks(bd_srv_t *, aoff64_t *);
     69static errno_t rd_open(bd_srvs_t *, bd_srv_t *);
     70static errno_t rd_close(bd_srv_t *);
     71static errno_t rd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     72static errno_t rd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
     73static errno_t rd_get_block_size(bd_srv_t *, size_t *);
     74static errno_t rd_get_num_blocks(bd_srv_t *, aoff64_t *);
    7575
    7676/** This rwlock protects the ramdisk's data.
     
    100100
    101101/** Open device. */
    102 static int rd_open(bd_srvs_t *bds, bd_srv_t *bd)
     102static errno_t rd_open(bd_srvs_t *bds, bd_srv_t *bd)
    103103{
    104104        return EOK;
     
    106106
    107107/** Close device. */
    108 static int rd_close(bd_srv_t *bd)
     108static errno_t rd_close(bd_srv_t *bd)
    109109{
    110110        return EOK;
     
    112112
    113113/** Read blocks from the device. */
    114 static int rd_read_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt, void *buf,
     114static errno_t rd_read_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt, void *buf,
    115115    size_t size)
    116116{
     
    128128
    129129/** Write blocks to the device. */
    130 static int rd_write_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
     130static errno_t rd_write_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
    131131    const void *buf, size_t size)
    132132{
     
    147147{
    148148        sysarg_t size;
    149         int ret = sysinfo_get_value("rd.size", &size);
     149        errno_t ret = sysinfo_get_value("rd.size", &size);
    150150        if ((ret != EOK) || (size == 0)) {
    151151                printf("%s: No RAM disk found\n", NAME);
     
    197197
    198198/** Get device block size. */
    199 static int rd_get_block_size(bd_srv_t *bd, size_t *rsize)
     199static errno_t rd_get_block_size(bd_srv_t *bd, size_t *rsize)
    200200{
    201201        *rsize = block_size;
     
    204204
    205205/** Get number of blocks on device. */
    206 static int rd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
     206static errno_t rd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
    207207{
    208208        *rnb = rd_size / block_size;
Note: See TracChangeset for help on using the changeset viewer.