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

    r36f0738 rb7fd2a0  
    4242static uint8_t inet_protocol = 0;
    4343
    44 static int inet_callback_create(void)
     44static errno_t inet_callback_create(void)
    4545{
    4646        async_exch_t *exch = async_exchange_begin(inet_sess);
     
    5050       
    5151        port_id_t port;
    52         int rc = async_create_callback_port(exch, INTERFACE_INET_CB, 0, 0,
     52        errno_t rc = async_create_callback_port(exch, INTERFACE_INET_CB, 0, 0,
    5353            inet_cb_conn, NULL, &port);
    5454       
     
    5858                return rc;
    5959       
    60         int retval;
     60        errno_t retval;
    6161        async_wait_for(req, &retval);
    6262       
     
    6464}
    6565
    66 static int inet_set_proto(uint8_t protocol)
    67 {
    68         async_exch_t *exch = async_exchange_begin(inet_sess);
    69         int rc = async_req_1_0(exch, INET_SET_PROTO, protocol);
     66static errno_t inet_set_proto(uint8_t protocol)
     67{
     68        async_exch_t *exch = async_exchange_begin(inet_sess);
     69        errno_t rc = async_req_1_0(exch, INET_SET_PROTO, protocol);
    7070        async_exchange_end(exch);
    7171       
     
    7373}
    7474
    75 int inet_init(uint8_t protocol, inet_ev_ops_t *ev_ops)
     75errno_t inet_init(uint8_t protocol, inet_ev_ops_t *ev_ops)
    7676{
    7777        service_id_t inet_svc;
    78         int rc;
     78        errno_t rc;
    7979
    8080        assert(inet_sess == NULL);
     
    110110}
    111111
    112 int inet_send(inet_dgram_t *dgram, uint8_t ttl, inet_df_t df)
     112errno_t inet_send(inet_dgram_t *dgram, uint8_t ttl, inet_df_t df)
    113113{
    114114        async_exch_t *exch = async_exchange_begin(inet_sess);
     
    118118            ttl, df, &answer);
    119119       
    120         int rc = async_data_write_start(exch, &dgram->src, sizeof(inet_addr_t));
     120        errno_t rc = async_data_write_start(exch, &dgram->src, sizeof(inet_addr_t));
    121121        if (rc != EOK) {
    122122                async_exchange_end(exch);
     
    141141        }
    142142       
    143         int retval;
     143        errno_t retval;
    144144        async_wait_for(req, &retval);
    145145       
     
    147147}
    148148
    149 int inet_get_srcaddr(inet_addr_t *remote, uint8_t tos, inet_addr_t *local)
     149errno_t inet_get_srcaddr(inet_addr_t *remote, uint8_t tos, inet_addr_t *local)
    150150{
    151151        async_exch_t *exch = async_exchange_begin(inet_sess);
     
    154154        aid_t req = async_send_1(exch, INET_GET_SRCADDR, tos, &answer);
    155155       
    156         int rc = async_data_write_start(exch, remote, sizeof(inet_addr_t));
     156        errno_t rc = async_data_write_start(exch, remote, sizeof(inet_addr_t));
    157157        if (rc != EOK) {
    158158                async_exchange_end(exch);
     
    170170        }
    171171       
    172         int retval;
     172        errno_t retval;
    173173        async_wait_for(req, &retval);
    174174       
     
    197197        }
    198198       
    199         int rc = async_data_write_finalize(callid, &dgram.src, size);
     199        errno_t rc = async_data_write_finalize(callid, &dgram.src, size);
    200200        if (rc != EOK) {
    201201                async_answer_0(callid, rc);
Note: See TracChangeset for help on using the changeset viewer.