Changeset b7fd2a0 in mainline for uspace/lib/c/generic/io/chardev.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/lib/c/generic/io/chardev.c

    r36f0738 rb7fd2a0  
    5050 * @return EOK on success, ENOMEM if out of memory, EIO on I/O error
    5151 */
    52 int chardev_open(async_sess_t *sess, chardev_t **rchardev)
     52errno_t chardev_open(async_sess_t *sess, chardev_t **rchardev)
    5353{
    5454        chardev_t *chardev;
     
    9494 * @return EOK on success or non-zero error code
    9595 */
    96 int chardev_read(chardev_t *chardev, void *buf, size_t size, size_t *nread)
     96errno_t chardev_read(chardev_t *chardev, void *buf, size_t size, size_t *nread)
    9797{
    9898        async_exch_t *exch = async_exchange_begin(chardev->sess);
     
    105105        ipc_call_t answer;
    106106        aid_t req = async_send_0(exch, CHARDEV_READ, &answer);
    107         int rc = async_data_read_start(exch, buf, size);
     107        errno_t rc = async_data_read_start(exch, buf, size);
    108108        async_exchange_end(exch);
    109109
     
    114114        }
    115115
    116         int retval;
     116        errno_t retval;
    117117        async_wait_for(req, &retval);
    118118
     
    124124        *nread = IPC_GET_ARG2(answer);
    125125        /* In case of partial success, ARG1 contains the error code */
    126         return (int) IPC_GET_ARG1(answer);
     126        return (errno_t) IPC_GET_ARG1(answer);
    127127
    128128}
     
    144144 * @return EOK on success or non-zero error code
    145145 */
    146 static int chardev_write_once(chardev_t *chardev, const void *data,
     146static errno_t chardev_write_once(chardev_t *chardev, const void *data,
    147147    size_t size, size_t *nwritten)
    148148{
     
    150150        ipc_call_t answer;
    151151        aid_t req;
    152         int rc;
     152        errno_t rc;
    153153
    154154        /* Break down large transfers */
     
    166166        }
    167167
    168         int retval;
     168        errno_t retval;
    169169        async_wait_for(req, &retval);
    170170        if (retval != EOK) {
     
    175175        *nwritten = IPC_GET_ARG2(answer);
    176176        /* In case of partial success, ARG1 contains the error code */
    177         return (int) IPC_GET_ARG1(answer);
     177        return (errno_t) IPC_GET_ARG1(answer);
    178178}
    179179
     
    193193 * @return EOK on success or non-zero error code
    194194 */
    195 int chardev_write(chardev_t *chardev, const void *data, size_t size,
     195errno_t chardev_write(chardev_t *chardev, const void *data, size_t size,
    196196    size_t *nwritten)
    197197{
    198198        size_t nw;
    199199        size_t p;
    200         int rc;
     200        errno_t rc;
    201201
    202202        p = 0;
Note: See TracChangeset for help on using the changeset viewer.