Changeset b7fd2a0 in mainline for uspace/lib/c/generic/device


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.

Location:
uspace/lib/c/generic/device
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/device/clock_dev.c

    r36f0738 rb7fd2a0  
    4646 * @return         EOK on success or an error code
    4747 */
    48 int
     48errno_t
    4949clock_dev_time_get(async_sess_t *sess, struct tm *t)
    5050{
    5151        aid_t req;
    52         int ret;
     52        errno_t ret;
    5353
    5454        async_exch_t *exch = async_exchange_begin(sess);
     
    6060        async_exchange_end(exch);
    6161
    62         int rc;
     62        errno_t rc;
    6363        if (ret != EOK) {
    6464                async_forget(req);
     
    6767
    6868        async_wait_for(req, &rc);
    69         return (int)rc;
     69        return (errno_t)rc;
    7070}
    7171
     
    7777 * @return       EOK on success or an error code
    7878 */
    79 int
     79errno_t
    8080clock_dev_time_set(async_sess_t *sess, struct tm *t)
    8181{
    8282        aid_t req;
    83         int ret;
     83        errno_t ret;
    8484
    8585        async_exch_t *exch = async_exchange_begin(sess);
     
    9191        async_exchange_end(exch);
    9292
    93         int rc;
     93        errno_t rc;
    9494        if (ret != EOK) {
    9595                async_forget(req);
     
    9898
    9999        async_wait_for(req, &rc);
    100         return (int)rc;
     100        return (errno_t)rc;
    101101}
    102102
  • uspace/lib/c/generic/device/hw_res.c

    r36f0738 rb7fd2a0  
    3838#include <stdlib.h>
    3939
    40 int hw_res_get_resource_list(async_sess_t *sess,
     40errno_t hw_res_get_resource_list(async_sess_t *sess,
    4141    hw_resource_list_t *hw_resources)
    4242{
     
    4545        async_exch_t *exch = async_exchange_begin(sess);
    4646       
    47         int rc = async_req_1_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     47        errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    4848            HW_RES_GET_RESOURCE_LIST, &count);
    4949       
     
    7575}
    7676
    77 int hw_res_enable_interrupt(async_sess_t *sess, int irq)
     77errno_t hw_res_enable_interrupt(async_sess_t *sess, int irq)
    7878{
    7979        async_exch_t *exch = async_exchange_begin(sess);
    8080       
    81         int rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     81        errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    8282            HW_RES_ENABLE_INTERRUPT, irq);
    8383        async_exchange_end(exch);
     
    8686}
    8787
    88 int hw_res_disable_interrupt(async_sess_t *sess, int irq)
     88errno_t hw_res_disable_interrupt(async_sess_t *sess, int irq)
    8989{
    9090        async_exch_t *exch = async_exchange_begin(sess);
    9191       
    92         int rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     92        errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    9393            HW_RES_DISABLE_INTERRUPT, irq);
    9494        async_exchange_end(exch);
     
    9797}
    9898
    99 int hw_res_clear_interrupt(async_sess_t *sess, int irq)
     99errno_t hw_res_clear_interrupt(async_sess_t *sess, int irq)
    100100{
    101101        async_exch_t *exch = async_exchange_begin(sess);
    102102       
    103         int rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     103        errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    104104            HW_RES_CLEAR_INTERRUPT, irq);
    105105        async_exchange_end(exch);
     
    122122 *
    123123 */
    124 int hw_res_dma_channel_setup(async_sess_t *sess,
     124errno_t hw_res_dma_channel_setup(async_sess_t *sess,
    125125    unsigned channel, uint32_t pa, uint32_t size, uint8_t mode)
    126126{
     
    128128       
    129129        const uint32_t packed = (channel & 0xffff) | (mode << 16);
    130         const int ret = async_req_4_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     130        const errno_t ret = async_req_4_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    131131            HW_RES_DMA_CHANNEL_SETUP, packed, pa, size);
    132132       
     
    145145 *
    146146 */
    147 int hw_res_dma_channel_remain(async_sess_t *sess, unsigned channel, size_t *rem)
     147errno_t hw_res_dma_channel_remain(async_sess_t *sess, unsigned channel, size_t *rem)
    148148{
    149149        async_exch_t *exch = async_exchange_begin(sess);
    150150       
    151151        sysarg_t remain;
    152         const int ret = async_req_2_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     152        const errno_t ret = async_req_2_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    153153            HW_RES_DMA_CHANNEL_REMAIN, channel, &remain);
    154154       
  • uspace/lib/c/generic/device/hw_res_parsed.c

    r36f0738 rb7fd2a0  
    194194 *
    195195 */
    196 int hw_res_list_parse(const pio_window_t *win,
     196errno_t hw_res_list_parse(const pio_window_t *win,
    197197    const hw_resource_list_t *res, hw_res_list_parsed_t *out, int flags)
    198198{
     
    253253 *
    254254 */
    255 int hw_res_get_list_parsed(async_sess_t *sess,
     255errno_t hw_res_get_list_parsed(async_sess_t *sess,
    256256    hw_res_list_parsed_t *hw_res_parsed, int flags)
    257257{
    258258        pio_window_t pio_window;
    259         int rc;
     259        errno_t rc;
    260260
    261261        if (!hw_res_parsed)
  • uspace/lib/c/generic/device/led_dev.c

    r36f0738 rb7fd2a0  
    3939#include <device/led_dev.h>
    4040
    41 int led_dev_color_set(async_sess_t *sess, pixel_t pixel)
     41errno_t led_dev_color_set(async_sess_t *sess, pixel_t pixel)
    4242{
    4343        async_exch_t *exch = async_exchange_begin(sess);
     
    4848        async_exchange_end(exch);
    4949       
    50         int rc;
     50        errno_t rc;
    5151        async_wait_for(req, &rc);
    5252       
    53         return (int) rc;
     53        return (errno_t) rc;
    5454}
    5555
  • uspace/lib/c/generic/device/pio_window.c

    r36f0738 rb7fd2a0  
    3737#include <async.h>
    3838
    39 int pio_window_get(async_sess_t *sess, pio_window_t *pio_win)
     39errno_t pio_window_get(async_sess_t *sess, pio_window_t *pio_win)
    4040{
    41         int rc;
     41        errno_t rc;
    4242
    4343        async_exch_t *exch = async_exchange_begin(sess);
Note: See TracChangeset for help on using the changeset viewer.