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

    r36f0738 rb7fd2a0  
    6666
    6767static void print_usage(void);
    68 static int file_bd_init(const char *fname);
     68static errno_t file_bd_init(const char *fname);
    6969static void file_bd_connection(ipc_callid_t iid, ipc_call_t *icall, void *);
    7070
    71 static int file_bd_open(bd_srvs_t *, bd_srv_t *);
    72 static int file_bd_close(bd_srv_t *);
    73 static int file_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
    74 static int file_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
    75 static int file_bd_get_block_size(bd_srv_t *, size_t *);
    76 static int file_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
     71static errno_t file_bd_open(bd_srvs_t *, bd_srv_t *);
     72static errno_t file_bd_close(bd_srv_t *);
     73static errno_t file_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     74static errno_t file_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
     75static errno_t file_bd_get_block_size(bd_srv_t *, size_t *);
     76static errno_t file_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
    7777
    7878static bd_ops_t file_bd_ops = {
     
    8787int main(int argc, char **argv)
    8888{
    89         int rc;
     89        errno_t rc;
    9090        char *image_name;
    9191        char *device_name;
     
    166166}
    167167
    168 static int file_bd_init(const char *fname)
     168static errno_t file_bd_init(const char *fname)
    169169{
    170170        bd_srvs_init(&bd_srvs);
     
    172172       
    173173        async_set_fallback_port_handler(file_bd_connection, NULL);
    174         int rc = loc_server_register(NAME);
     174        errno_t rc = loc_server_register(NAME);
    175175        if (rc != EOK) {
    176176                printf("%s: Unable to register driver.\n", NAME);
     
    206206
    207207/** Open device. */
    208 static int file_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
     208static errno_t file_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    209209{
    210210        return EOK;
     
    212212
    213213/** Close device. */
    214 static int file_bd_close(bd_srv_t *bd)
     214static errno_t file_bd_close(bd_srv_t *bd)
    215215{
    216216        return EOK;
     
    218218
    219219/** Read blocks from the device. */
    220 static int file_bd_read_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt, void *buf,
     220static errno_t file_bd_read_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt, void *buf,
    221221    size_t size)
    222222{
     
    258258
    259259/** Write blocks to the device. */
    260 static int file_bd_write_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt,
     260static errno_t file_bd_write_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt,
    261261    const void *buf, size_t size)
    262262{
     
    300300
    301301/** Get device block size. */
    302 static int file_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
     302static errno_t file_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
    303303{
    304304        *rsize = block_size;
     
    307307
    308308/** Get number of blocks on device. */
    309 static int file_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
     309static errno_t file_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
    310310{
    311311        *rnb = num_blocks;
Note: See TracChangeset for help on using the changeset viewer.