Changeset b7fd2a0 in mainline for uspace/srv/net/tcp


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/srv/net/tcp
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tcp/conn.c

    r36f0738 rb7fd2a0  
    8484
    8585/** Initialize connections. */
    86 int tcp_conns_init(void)
    87 {
    88         int rc;
     86errno_t tcp_conns_init(void)
     87{
     88        errno_t rc;
    8989
    9090        rc = amap_create(&amap);
     
    303303 * Add connection to the connection map.
    304304 */
    305 int tcp_conn_add(tcp_conn_t *conn)
     305errno_t tcp_conn_add(tcp_conn_t *conn)
    306306{
    307307        inet_ep2_t aepp;
    308         int rc;
     308        errno_t rc;
    309309
    310310        tcp_conn_addref(conn);
     
    425425tcp_conn_t *tcp_conn_find_ref(inet_ep2_t *epp)
    426426{
    427         int rc;
     427        errno_t rc;
    428428        void *arg;
    429429        tcp_conn_t *conn;
     
    12421242        inet_ep2_t aepp;
    12431243        inet_ep2_t oldepp;
    1244         int rc;
     1244        errno_t rc;
    12451245
    12461246        log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_conn_segment_arrived(%p)",
  • uspace/srv/net/tcp/conn.h

    r36f0738 rb7fd2a0  
    4040#include "tcp_type.h"
    4141
    42 extern int tcp_conns_init(void);
     42extern errno_t tcp_conns_init(void);
    4343extern void tcp_conns_fini(void);
    4444extern tcp_conn_t *tcp_conn_new(inet_ep2_t *);
    4545extern void tcp_conn_delete(tcp_conn_t *);
    46 extern int tcp_conn_add(tcp_conn_t *);
     46extern errno_t tcp_conn_add(tcp_conn_t *);
    4747extern void tcp_conn_reset(tcp_conn_t *conn);
    4848extern void tcp_conn_sync(tcp_conn_t *);
  • uspace/srv/net/tcp/inet.c

    r36f0738 rb7fd2a0  
    5050#define NAME       "tcp"
    5151
    52 static int tcp_inet_ev_recv(inet_dgram_t *dgram);
     52static errno_t tcp_inet_ev_recv(inet_dgram_t *dgram);
    5353static void tcp_received_pdu(tcp_pdu_t *pdu);
    5454
     
    5858
    5959/** Received datagram callback */
    60 static int tcp_inet_ev_recv(inet_dgram_t *dgram)
     60static errno_t tcp_inet_ev_recv(inet_dgram_t *dgram)
    6161{
    6262        uint8_t *pdu_raw;
     
    121121void tcp_transmit_pdu(tcp_pdu_t *pdu)
    122122{
    123         int rc;
     123        errno_t rc;
    124124        uint8_t *pdu_raw;
    125125        size_t pdu_raw_size;
     
    169169
    170170/** Initialize TCP inet interface. */
    171 int tcp_inet_init(void)
     171errno_t tcp_inet_init(void)
    172172{
    173         int rc;
     173        errno_t rc;
    174174
    175175        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_inet_init()");
  • uspace/srv/net/tcp/inet.h

    r36f0738 rb7fd2a0  
    3838#include "tcp_type.h"
    3939
    40 extern int tcp_inet_init(void);
     40extern errno_t tcp_inet_init(void);
    4141extern void tcp_transmit_pdu(tcp_pdu_t *);
    4242
  • uspace/srv/net/tcp/iqueue.c

    r36f0738 rb7fd2a0  
    137137 * @return              EOK on success, ENOENT if no segment is ready
    138138 */
    139 int tcp_iqueue_get_ready_seg(tcp_iqueue_t *iqueue, tcp_segment_t **seg)
     139errno_t tcp_iqueue_get_ready_seg(tcp_iqueue_t *iqueue, tcp_segment_t **seg)
    140140{
    141141        tcp_iqueue_entry_t *iqe;
  • uspace/srv/net/tcp/iqueue.h

    r36f0738 rb7fd2a0  
    4141extern void tcp_iqueue_insert_seg(tcp_iqueue_t *, tcp_segment_t *);
    4242extern void tcp_iqueue_remove_seg(tcp_iqueue_t *, tcp_segment_t *);
    43 extern int tcp_iqueue_get_ready_seg(tcp_iqueue_t *, tcp_segment_t **);
     43extern errno_t tcp_iqueue_get_ready_seg(tcp_iqueue_t *, tcp_segment_t **);
    4444
    4545#endif
  • uspace/srv/net/tcp/ncsim.c

    r36f0738 rb7fd2a0  
    123123
    124124/** Network condition simulator handler fibril. */
    125 static int tcp_ncsim_fibril(void *arg)
     125static errno_t tcp_ncsim_fibril(void *arg)
    126126{
    127127        link_t *link;
    128128        tcp_squeue_entry_t *sqe;
    129129        inet_ep2_t rident;
    130         int rc;
     130        errno_t rc;
    131131
    132132        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_ncsim_fibril()");
  • uspace/srv/net/tcp/pdu.c

    r36f0738 rb7fd2a0  
    191191}
    192192
    193 static int tcp_header_encode(inet_ep2_t *epp, tcp_segment_t *seg,
     193static errno_t tcp_header_encode(inet_ep2_t *epp, tcp_segment_t *seg,
    194194    void **header, size_t *size)
    195195{
     
    295295
    296296/** Decode incoming PDU */
    297 int tcp_pdu_decode(tcp_pdu_t *pdu, inet_ep2_t *epp, tcp_segment_t **seg)
     297errno_t tcp_pdu_decode(tcp_pdu_t *pdu, inet_ep2_t *epp, tcp_segment_t **seg)
    298298{
    299299        tcp_segment_t *nseg;
     
    319319
    320320/** Encode outgoing PDU */
    321 int tcp_pdu_encode(inet_ep2_t *epp, tcp_segment_t *seg, tcp_pdu_t **pdu)
     321errno_t tcp_pdu_encode(inet_ep2_t *epp, tcp_segment_t *seg, tcp_pdu_t **pdu)
    322322{
    323323        tcp_pdu_t *npdu;
    324324        size_t text_size;
    325325        uint16_t checksum;
    326         int rc;
     326        errno_t rc;
    327327
    328328        npdu = tcp_pdu_new();
  • uspace/srv/net/tcp/pdu.h

    r36f0738 rb7fd2a0  
    4343extern tcp_pdu_t *tcp_pdu_create(void *, size_t, void *, size_t);
    4444extern void tcp_pdu_delete(tcp_pdu_t *);
    45 extern int tcp_pdu_decode(tcp_pdu_t *, inet_ep2_t *, tcp_segment_t **);
    46 extern int tcp_pdu_encode(inet_ep2_t *, tcp_segment_t *, tcp_pdu_t **);
     45extern errno_t tcp_pdu_decode(tcp_pdu_t *, inet_ep2_t *, tcp_segment_t **);
     46extern errno_t tcp_pdu_encode(inet_ep2_t *, tcp_segment_t *, tcp_pdu_t **);
    4747
    4848#endif
  • uspace/srv/net/tcp/rqueue.c

    r36f0738 rb7fd2a0  
    105105
    106106/** Receive queue handler fibril. */
    107 static int tcp_rqueue_fibril(void *arg)
     107static errno_t tcp_rqueue_fibril(void *arg)
    108108{
    109109        link_t *link;
  • uspace/srv/net/tcp/service.c

    r36f0738 rb7fd2a0  
    6868static void tcp_service_lst_cstate_change(tcp_conn_t *, void *, tcp_cstate_t);
    6969
    70 static int tcp_cconn_create(tcp_client_t *, tcp_conn_t *, tcp_cconn_t **);
     70static errno_t tcp_cconn_create(tcp_client_t *, tcp_conn_t *, tcp_cconn_t **);
    7171
    7272/** Connection callbacks to tie us to lower layer */
     
    132132        tcp_cconn_t *cconn;
    133133        inet_ep2_t epp;
    134         int rc;
     134        errno_t rc;
    135135        tcp_error_t trc;
    136136
     
    298298 * @return EOK on success or ENOMEM if out of memory
    299299 */
    300 static int tcp_cconn_create(tcp_client_t *client, tcp_conn_t *conn,
     300static errno_t tcp_cconn_create(tcp_client_t *client, tcp_conn_t *conn,
    301301    tcp_cconn_t **rcconn)
    302302{
     
    345345 * @return EOK on success or ENOMEM if out of memory
    346346 */
    347 static int tcp_clistener_create(tcp_client_t *client, tcp_conn_t *conn,
     347static errno_t tcp_clistener_create(tcp_client_t *client, tcp_conn_t *conn,
    348348    tcp_clst_t **rclst)
    349349{
     
    390390 *         is found.
    391391 */
    392 static int tcp_cconn_get(tcp_client_t *client, sysarg_t id,
     392static errno_t tcp_cconn_get(tcp_client_t *client, sysarg_t id,
    393393    tcp_cconn_t **rcconn)
    394394{
     
    412412 *         is found.
    413413 */
    414 static int tcp_clistener_get(tcp_client_t *client, sysarg_t id,
     414static errno_t tcp_clistener_get(tcp_client_t *client, sysarg_t id,
    415415    tcp_clst_t **rclst)
    416416{
     
    435435 * @return EOK on success or an error code
    436436 */
    437 static int tcp_conn_create_impl(tcp_client_t *client, inet_ep2_t *epp,
     437static errno_t tcp_conn_create_impl(tcp_client_t *client, inet_ep2_t *epp,
    438438    sysarg_t *rconn_id)
    439439{
    440440        tcp_conn_t *conn;
    441441        tcp_cconn_t *cconn;
    442         int rc;
     442        errno_t rc;
    443443        tcp_error_t trc;
    444444        char *slocal;
     
    482482 * @return EOK on success, ENOENT if no such connection is found
    483483 */
    484 static int tcp_conn_destroy_impl(tcp_client_t *client, sysarg_t conn_id)
     484static errno_t tcp_conn_destroy_impl(tcp_client_t *client, sysarg_t conn_id)
    485485{
    486486        tcp_cconn_t *cconn;
    487         int rc;
     487        errno_t rc;
    488488
    489489        rc = tcp_cconn_get(client, conn_id, &cconn);
     
    509509 * @return EOK on success or an error code
    510510*/
    511 static int tcp_listener_create_impl(tcp_client_t *client, inet_ep_t *ep,
     511static errno_t tcp_listener_create_impl(tcp_client_t *client, inet_ep_t *ep,
    512512    sysarg_t *rlst_id)
    513513{
     
    515515        tcp_clst_t *clst;
    516516        inet_ep2_t epp;
    517         int rc;
     517        errno_t rc;
    518518        tcp_error_t trc;
    519519
     
    555555 * @return EOK on success, ENOENT if no such listener is found
    556556 */
    557 static int tcp_listener_destroy_impl(tcp_client_t *client, sysarg_t lst_id)
     557static errno_t tcp_listener_destroy_impl(tcp_client_t *client, sysarg_t lst_id)
    558558{
    559559        tcp_clst_t *clst;
    560         int rc;
     560        errno_t rc;
    561561
    562562        rc = tcp_clistener_get(client, lst_id, &clst);
     
    580580 * @return EOK on success or an error code
    581581 */
    582 static int tcp_conn_send_fin_impl(tcp_client_t *client, sysarg_t conn_id)
     582static errno_t tcp_conn_send_fin_impl(tcp_client_t *client, sysarg_t conn_id)
    583583{
    584584        tcp_cconn_t *cconn;
    585         int rc;
     585        errno_t rc;
    586586
    587587        rc = tcp_cconn_get(client, conn_id, &cconn);
     
    605605 * @return EOK on success or an error code
    606606 */
    607 static int tcp_conn_push_impl(tcp_client_t *client, sysarg_t conn_id)
     607static errno_t tcp_conn_push_impl(tcp_client_t *client, sysarg_t conn_id)
    608608{
    609609        tcp_cconn_t *cconn;
    610         int rc;
     610        errno_t rc;
    611611
    612612        rc = tcp_cconn_get(client, conn_id, &cconn);
     
    630630 * @return EOK on success or an error code
    631631 */
    632 static int tcp_conn_reset_impl(tcp_client_t *client, sysarg_t conn_id)
     632static errno_t tcp_conn_reset_impl(tcp_client_t *client, sysarg_t conn_id)
    633633{
    634634        tcp_cconn_t *cconn;
    635         int rc;
     635        errno_t rc;
    636636
    637637        rc = tcp_cconn_get(client, conn_id, &cconn);
     
    656656 * @return EOK on success or an error code
    657657 */
    658 static int tcp_conn_send_impl(tcp_client_t *client, sysarg_t conn_id,
     658static errno_t tcp_conn_send_impl(tcp_client_t *client, sysarg_t conn_id,
    659659    void *data, size_t size)
    660660{
    661661        tcp_cconn_t *cconn;
    662         int rc;
     662        errno_t rc;
    663663        tcp_error_t trc;
    664664
     
    686686 * @return EOK on success or an error code
    687687 */
    688 static int tcp_conn_recv_impl(tcp_client_t *client, sysarg_t conn_id,
     688static errno_t tcp_conn_recv_impl(tcp_client_t *client, sysarg_t conn_id,
    689689    void *data, size_t size, size_t *nrecv)
    690690{
    691691        tcp_cconn_t *cconn;
    692692        xflags_t xflags;
    693         int rc;
     693        errno_t rc;
    694694        tcp_error_t trc;
    695695
     
    758758        inet_ep2_t epp;
    759759        sysarg_t conn_id;
    760         int rc;
     760        errno_t rc;
    761761
    762762        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_create_srv()");
     
    802802{
    803803        sysarg_t conn_id;
    804         int rc;
     804        errno_t rc;
    805805
    806806        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_destroy_srv()");
     
    826826        inet_ep_t ep;
    827827        sysarg_t lst_id;
    828         int rc;
     828        errno_t rc;
    829829
    830830        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_listener_create_srv()");
     
    870870{
    871871        sysarg_t lst_id;
    872         int rc;
     872        errno_t rc;
    873873
    874874        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_listener_destroy_srv()");
     
    891891{
    892892        sysarg_t conn_id;
    893         int rc;
     893        errno_t rc;
    894894
    895895        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_send_fin_srv()");
     
    912912{
    913913        sysarg_t conn_id;
    914         int rc;
     914        errno_t rc;
    915915
    916916        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_push_srv()");
     
    933933{
    934934        sysarg_t conn_id;
    935         int rc;
     935        errno_t rc;
    936936
    937937        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_reset_srv()");
     
    957957        sysarg_t conn_id;
    958958        void *data;
    959         int rc;
     959        errno_t rc;
    960960
    961961        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_send_srv())");
     
    10181018        size_t size, rsize;
    10191019        void *data;
    1020         int rc;
     1020        errno_t rc;
    10211021
    10221022        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_recv_srv()");
     
    10741074        size_t size, rsize;
    10751075        void *data;
    1076         int rc;
     1076        errno_t rc;
    10771077
    10781078        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_recv_wait_srv()");
     
    12461246 * @return EOK on success or an error code.
    12471247 */
    1248 int tcp_service_init(void)
    1249 {
    1250         int rc;
     1248errno_t tcp_service_init(void)
     1249{
     1250        errno_t rc;
    12511251        service_id_t sid;
    12521252
  • uspace/srv/net/tcp/service.h

    r36f0738 rb7fd2a0  
    3636#define SERVICE_H
    3737
    38 extern int tcp_service_init(void);
     38extern errno_t tcp_service_init(void);
    3939
    4040#endif
  • uspace/srv/net/tcp/tcp.c

    r36f0738 rb7fd2a0  
    5555};
    5656
    57 static int tcp_init(void)
     57static errno_t tcp_init(void)
    5858{
    59         int rc;
     59        errno_t rc;
    6060
    6161        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_init()");
     
    9191int main(int argc, char **argv)
    9292{
    93         int rc;
     93        errno_t rc;
    9494
    9595        printf(NAME ": TCP (Transmission Control Protocol) network module\n");
  • uspace/srv/net/tcp/test.c

    r36f0738 rb7fd2a0  
    4747#define RCV_BUF_SIZE 64
    4848
    49 static int test_srv(void *arg)
     49static errno_t test_srv(void *arg)
    5050{
    5151        tcp_conn_t *conn;
     
    9191}
    9292
    93 static int test_cli(void *arg)
     93static errno_t test_cli(void *arg)
    9494{
    9595        tcp_conn_t *conn;
  • uspace/srv/net/tcp/test/conn.c

    r36f0738 rb7fd2a0  
    4646PCUT_TEST_BEFORE
    4747{
    48         int rc;
     48        errno_t rc;
    4949
    5050        /* We will be calling functions that perform logging */
     
    8989        tcp_conn_t *conn, *cfound;
    9090        inet_ep2_t epp;
    91         int rc;
     91        errno_t rc;
    9292
    9393        inet_ep2_init(&epp);
     
    119119        tcp_conn_t *conn;
    120120        inet_ep2_t epp;
    121         int rc;
     121        errno_t rc;
    122122
    123123        inet_ep2_init(&epp);
     
    152152        tcp_conn_t *cconn, *sconn;
    153153        inet_ep2_t cepp, sepp;
    154         int rc;
     154        errno_t rc;
    155155
    156156        /* Client EPP */
  • uspace/srv/net/tcp/test/iqueue.c

    r36f0738 rb7fd2a0  
    4545        inet_ep2_t epp;
    4646        tcp_segment_t *rseg;
    47         int rc;
     47        errno_t rc;
    4848
    4949        inet_ep2_init(&epp);
     
    7171        void *data;
    7272        size_t dsize;
    73         int rc;
     73        errno_t rc;
    7474
    7575        inet_ep2_init(&epp);
     
    117117        void *data;
    118118        size_t dsize;
    119         int rc;
     119        errno_t rc;
    120120
    121121        inet_ep2_init(&epp);
  • uspace/srv/net/tcp/test/pdu.c

    r36f0738 rb7fd2a0  
    4747        tcp_pdu_t *pdu;
    4848        inet_ep2_t epp, depp;
    49         int rc;
     49        errno_t rc;
    5050
    5151        inet_ep2_init(&epp);
     
    7878        uint8_t *data;
    7979        size_t i, dsize;
    80         int rc;
     80        errno_t rc;
    8181
    8282        inet_ep2_init(&epp);
  • uspace/srv/net/tcp/test/rqueue.c

    r36f0738 rb7fd2a0  
    5959PCUT_TEST_BEFORE
    6060{
    61         int rc;
     61        errno_t rc;
    6262
    6363        /* We will be calling functions that perform logging */
  • uspace/srv/net/tcp/test/tqueue.c

    r36f0738 rb7fd2a0  
    5353PCUT_TEST_BEFORE
    5454{
    55         int rc;
     55        errno_t rc;
    5656
    5757        /* We will be calling functions that perform logging */
  • uspace/srv/net/tcp/test/ucall.c

    r36f0738 rb7fd2a0  
    6060PCUT_TEST_BEFORE
    6161{
    62         int rc;
     62        errno_t rc;
    6363
    6464        /* We will be calling functions that perform logging */
  • uspace/srv/net/tcp/tqueue.c

    r36f0738 rb7fd2a0  
    6363static void tcp_tqueue_send_immed(tcp_conn_t *, tcp_segment_t *);
    6464
    65 int tcp_tqueue_init(tcp_tqueue_t *tqueue, tcp_conn_t *conn,
     65errno_t tcp_tqueue_init(tcp_tqueue_t *tqueue, tcp_conn_t *conn,
    6666    tcp_tqueue_cb_t *cb)
    6767{
  • uspace/srv/net/tcp/tqueue.h

    r36f0738 rb7fd2a0  
    4040#include "tcp_type.h"
    4141
    42 extern int tcp_tqueue_init(tcp_tqueue_t *, tcp_conn_t *,
     42extern errno_t tcp_tqueue_init(tcp_tqueue_t *, tcp_conn_t *,
    4343    tcp_tqueue_cb_t *);
    4444extern void tcp_tqueue_clear(tcp_tqueue_t *);
  • uspace/srv/net/tcp/ucall.c

    r36f0738 rb7fd2a0  
    6969{
    7070        tcp_conn_t *nconn;
    71         int rc;
     71        errno_t rc;
    7272
    7373        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_open(%p, %s, %s, %p)",
Note: See TracChangeset for help on using the changeset viewer.