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

    r36f0738 rb7fd2a0  
    4242
    4343static void tcp_cb_conn(ipc_callid_t, ipc_call_t *, void *);
    44 static int tcp_conn_fibril(void *);
     44static errno_t tcp_conn_fibril(void *);
    4545
    4646/** Incoming TCP connection info
     
    6161 * @return EOK on success or an error code
    6262 */
    63 static int tcp_callback_create(tcp_t *tcp)
     63static errno_t tcp_callback_create(tcp_t *tcp)
    6464{
    6565        async_exch_t *exch = async_exchange_begin(tcp->sess);
     
    6868       
    6969        port_id_t port;
    70         int rc = async_create_callback_port(exch, INTERFACE_TCP_CB, 0, 0,
     70        errno_t rc = async_create_callback_port(exch, INTERFACE_TCP_CB, 0, 0,
    7171            tcp_cb_conn, tcp, &port);
    7272       
     
    7676                return rc;
    7777
    78         int retval;
     78        errno_t retval;
    7979        async_wait_for(req, &retval);
    8080
     
    8888 *         cannot be contacted
    8989 */
    90 int tcp_create(tcp_t **rtcp)
     90errno_t tcp_create(tcp_t **rtcp)
    9191{
    9292        tcp_t *tcp;
    9393        service_id_t tcp_svcid;
    94         int rc;
     94        errno_t rc;
    9595
    9696        tcp = calloc(1, sizeof(tcp_t));
     
    161161 * @return EOK on success, ENOMEM if out of memory
    162162 */
    163 static int tcp_conn_new(tcp_t *tcp, sysarg_t id, tcp_cb_t *cb, void *arg,
     163static errno_t tcp_conn_new(tcp_t *tcp, sysarg_t id, tcp_cb_t *cb, void *arg,
    164164    tcp_conn_t **rconn)
    165165{
     
    207207 * @return EOK on success or an error code.
    208208 */
    209 int tcp_conn_create(tcp_t *tcp, inet_ep2_t *epp, tcp_cb_t *cb, void *arg,
     209errno_t tcp_conn_create(tcp_t *tcp, inet_ep2_t *epp, tcp_cb_t *cb, void *arg,
    210210    tcp_conn_t **rconn)
    211211{
     
    216216        exch = async_exchange_begin(tcp->sess);
    217217        aid_t req = async_send_0(exch, TCP_CONN_CREATE, &answer);
    218         int rc = async_data_write_start(exch, (void *)epp,
     218        errno_t rc = async_data_write_start(exch, (void *)epp,
    219219            sizeof(inet_ep2_t));
    220220        async_exchange_end(exch);
    221221
    222222        if (rc != EOK) {
    223                 int rc_orig;
     223                errno_t rc_orig;
    224224                async_wait_for(req, &rc_orig);
    225225                if (rc_orig != EOK)
     
    240240        return EOK;
    241241error:
    242         return (int) rc;
     242        return (errno_t) rc;
    243243}
    244244
     
    260260
    261261        exch = async_exchange_begin(conn->tcp->sess);
    262         int rc = async_req_1_0(exch, TCP_CONN_DESTROY, conn->id);
     262        errno_t rc = async_req_1_0(exch, TCP_CONN_DESTROY, conn->id);
    263263        async_exchange_end(exch);
    264264
     
    275275 * @return EOK on success, EINVAL if no connection with the given ID exists
    276276 */
    277 static int tcp_conn_get(tcp_t *tcp, sysarg_t id, tcp_conn_t **rconn)
     277static errno_t tcp_conn_get(tcp_t *tcp, sysarg_t id, tcp_conn_t **rconn)
    278278{
    279279        list_foreach(tcp->conn, ltcp, tcp_conn_t, conn) {
     
    318318 * @return EOK on success or an error code
    319319 */
    320 int tcp_listener_create(tcp_t *tcp, inet_ep_t *ep, tcp_listen_cb_t *lcb,
     320errno_t tcp_listener_create(tcp_t *tcp, inet_ep_t *ep, tcp_listen_cb_t *lcb,
    321321    void *larg, tcp_cb_t *cb, void *arg, tcp_listener_t **rlst)
    322322{
     
    331331        exch = async_exchange_begin(tcp->sess);
    332332        aid_t req = async_send_0(exch, TCP_LISTENER_CREATE, &answer);
    333         int rc = async_data_write_start(exch, (void *)ep,
     333        errno_t rc = async_data_write_start(exch, (void *)ep,
    334334            sizeof(inet_ep_t));
    335335        async_exchange_end(exch);
    336336
    337337        if (rc != EOK) {
    338                 int rc_orig;
     338                errno_t rc_orig;
    339339                async_wait_for(req, &rc_orig);
    340340                if (rc_orig != EOK)
     
    360360error:
    361361        free(lst);
    362         return (int) rc;
     362        return (errno_t) rc;
    363363}
    364364
     
    377377
    378378        exch = async_exchange_begin(lst->tcp->sess);
    379         int rc = async_req_1_0(exch, TCP_LISTENER_DESTROY, lst->id);
     379        errno_t rc = async_req_1_0(exch, TCP_LISTENER_DESTROY, lst->id);
    380380        async_exchange_end(exch);
    381381
     
    392392 * @return EOK on success, EINVAL if no listener with the given ID is found
    393393 */
    394 static int tcp_listener_get(tcp_t *tcp, sysarg_t id, tcp_listener_t **rlst)
     394static errno_t tcp_listener_get(tcp_t *tcp, sysarg_t id, tcp_listener_t **rlst)
    395395{
    396396        list_foreach(tcp->listener, ltcp, tcp_listener_t, lst) {
     
    424424 * @return EOK if connection is established, EIO otherwise
    425425 */
    426 int tcp_conn_wait_connected(tcp_conn_t *conn)
     426errno_t tcp_conn_wait_connected(tcp_conn_t *conn)
    427427{
    428428        fibril_mutex_lock(&conn->lock);
     
    448448 * @return EOK on success or an error code
    449449 */
    450 int tcp_conn_send(tcp_conn_t *conn, const void *data, size_t bytes)
    451 {
    452         async_exch_t *exch;
    453         int rc;
     450errno_t tcp_conn_send(tcp_conn_t *conn, const void *data, size_t bytes)
     451{
     452        async_exch_t *exch;
     453        errno_t rc;
    454454
    455455        exch = async_exchange_begin(conn->tcp->sess);
     
    480480 * @return EOK on success or an error code
    481481 */
    482 int tcp_conn_send_fin(tcp_conn_t *conn)
     482errno_t tcp_conn_send_fin(tcp_conn_t *conn)
    483483{
    484484        async_exch_t *exch;
    485485
    486486        exch = async_exchange_begin(conn->tcp->sess);
    487         int rc = async_req_1_0(exch, TCP_CONN_SEND_FIN, conn->id);
     487        errno_t rc = async_req_1_0(exch, TCP_CONN_SEND_FIN, conn->id);
    488488        async_exchange_end(exch);
    489489
     
    496496 * @return EOK on success or an error code
    497497 */
    498 int tcp_conn_push(tcp_conn_t *conn)
     498errno_t tcp_conn_push(tcp_conn_t *conn)
    499499{
    500500        async_exch_t *exch;
    501501
    502502        exch = async_exchange_begin(conn->tcp->sess);
    503         int rc = async_req_1_0(exch, TCP_CONN_PUSH, conn->id);
     503        errno_t rc = async_req_1_0(exch, TCP_CONN_PUSH, conn->id);
    504504        async_exchange_end(exch);
    505505
     
    512512 * @return EOK on success or an error code
    513513 */
    514 int tcp_conn_reset(tcp_conn_t *conn)
     514errno_t tcp_conn_reset(tcp_conn_t *conn)
    515515{
    516516        async_exch_t *exch;
    517517
    518518        exch = async_exchange_begin(conn->tcp->sess);
    519         int rc = async_req_1_0(exch, TCP_CONN_RESET, conn->id);
     519        errno_t rc = async_req_1_0(exch, TCP_CONN_RESET, conn->id);
    520520        async_exchange_end(exch);
    521521
     
    540540 *         error code in case of other error
    541541 */
    542 int tcp_conn_recv(tcp_conn_t *conn, void *buf, size_t bsize, size_t *nrecv)
     542errno_t tcp_conn_recv(tcp_conn_t *conn, void *buf, size_t bsize, size_t *nrecv)
    543543{
    544544        async_exch_t *exch;
     
    553553        exch = async_exchange_begin(conn->tcp->sess);
    554554        aid_t req = async_send_1(exch, TCP_CONN_RECV, conn->id, &answer);
    555         int rc = async_data_read_start(exch, buf, bsize);
     555        errno_t rc = async_data_read_start(exch, buf, bsize);
    556556        async_exchange_end(exch);
    557557
     
    562562        }
    563563
    564         int retval;
     564        errno_t retval;
    565565        async_wait_for(req, &retval);
    566566        if (retval != EOK) {
     
    588588 * @return EOK on success or an error code
    589589 */
    590 int tcp_conn_recv_wait(tcp_conn_t *conn, void *buf, size_t bsize,
     590errno_t tcp_conn_recv_wait(tcp_conn_t *conn, void *buf, size_t bsize,
    591591    size_t *nrecv)
    592592{
     
    602602        exch = async_exchange_begin(conn->tcp->sess);
    603603        aid_t req = async_send_1(exch, TCP_CONN_RECV_WAIT, conn->id, &answer);
    604         int rc = async_data_read_start(exch, buf, bsize);
     604        errno_t rc = async_data_read_start(exch, buf, bsize);
    605605        async_exchange_end(exch);
    606606
     
    616616        }
    617617
    618         int retval;
     618        errno_t retval;
    619619        async_wait_for(req, &retval);
    620620        if (retval != EOK) {
     
    641641        tcp_conn_t *conn;
    642642        sysarg_t conn_id;
    643         int rc;
     643        errno_t rc;
    644644
    645645        conn_id = IPC_GET_ARG1(*icall);
     
    669669        tcp_conn_t *conn;
    670670        sysarg_t conn_id;
    671         int rc;
     671        errno_t rc;
    672672
    673673        conn_id = IPC_GET_ARG1(*icall);
     
    697697        tcp_conn_t *conn;
    698698        sysarg_t conn_id;
    699         int rc;
     699        errno_t rc;
    700700
    701701        conn_id = IPC_GET_ARG1(*icall);
     
    725725        tcp_conn_t *conn;
    726726        sysarg_t conn_id;
    727         int rc;
     727        errno_t rc;
    728728
    729729        conn_id = IPC_GET_ARG1(*icall);
     
    769769        fid_t fid;
    770770        tcp_in_conn_t *cinfo;
    771         int rc;
     771        errno_t rc;
    772772
    773773        lst_id = IPC_GET_ARG1(*icall);
     
    863863 * @param arg Argument, incoming connection information (@c tcp_in_conn_t)
    864864 */
    865 static int tcp_conn_fibril(void *arg)
     865static errno_t tcp_conn_fibril(void *arg)
    866866{
    867867        tcp_in_conn_t *cinfo = (tcp_in_conn_t *)arg;
Note: See TracChangeset for help on using the changeset viewer.