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


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/udp
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/udp/assoc.c

    r36f0738 rb7fd2a0  
    5656
    5757static udp_assoc_t *udp_assoc_find_ref(inet_ep2_t *);
    58 static int udp_assoc_queue_msg(udp_assoc_t *, inet_ep2_t *, udp_msg_t *);
     58static errno_t udp_assoc_queue_msg(udp_assoc_t *, inet_ep2_t *, udp_msg_t *);
    5959
    6060/** Initialize associations. */
    61 int udp_assocs_init(void)
    62 {
    63         int rc;
     61errno_t udp_assocs_init(void)
     62{
     63        errno_t rc;
    6464
    6565        rc = amap_create(&amap);
     
    182182 * Add association to the association map.
    183183 */
    184 int udp_assoc_add(udp_assoc_t *assoc)
     184errno_t udp_assoc_add(udp_assoc_t *assoc)
    185185{
    186186        inet_ep2_t aepp;
    187         int rc;
     187        errno_t rc;
    188188
    189189        udp_assoc_addref(assoc);
     
    242242 *                      EIO if no route to destination exists
    243243 */
    244 int udp_assoc_send(udp_assoc_t *assoc, inet_ep_t *remote, udp_msg_t *msg)
     244errno_t udp_assoc_send(udp_assoc_t *assoc, inet_ep_t *remote, udp_msg_t *msg)
    245245{
    246246        udp_pdu_t *pdu;
    247247        inet_ep2_t epp;
    248         int rc;
     248        errno_t rc;
    249249
    250250        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send(%p, %p, %p)",
     
    302302 * Pull one message from the association's receive queue.
    303303 */
    304 int udp_assoc_recv(udp_assoc_t *assoc, udp_msg_t **msg, inet_ep_t *remote)
     304errno_t udp_assoc_recv(udp_assoc_t *assoc, udp_msg_t **msg, inet_ep_t *remote)
    305305{
    306306        link_t *link;
     
    341341{
    342342        udp_assoc_t *assoc;
    343         int rc;
     343        errno_t rc;
    344344
    345345        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_received(%p, %p)", repp, msg);
     
    380380}
    381381
    382 static int udp_assoc_queue_msg(udp_assoc_t *assoc, inet_ep2_t *epp,
     382static errno_t udp_assoc_queue_msg(udp_assoc_t *assoc, inet_ep2_t *epp,
    383383    udp_msg_t *msg)
    384384{
     
    416416static udp_assoc_t *udp_assoc_find_ref(inet_ep2_t *epp)
    417417{
    418         int rc;
     418        errno_t rc;
    419419        void *arg;
    420420        udp_assoc_t *assoc;
  • uspace/srv/net/udp/assoc.h

    r36f0738 rb7fd2a0  
    4040#include "udp_type.h"
    4141
    42 extern int udp_assocs_init(void);
     42extern errno_t udp_assocs_init(void);
    4343extern udp_assoc_t *udp_assoc_new(inet_ep2_t *, udp_assoc_cb_t *, void *);
    4444extern void udp_assoc_delete(udp_assoc_t *);
    45 extern int udp_assoc_add(udp_assoc_t *);
     45extern errno_t udp_assoc_add(udp_assoc_t *);
    4646extern void udp_assoc_remove(udp_assoc_t *);
    4747extern void udp_assoc_addref(udp_assoc_t *);
    4848extern void udp_assoc_delref(udp_assoc_t *);
    4949extern void udp_assoc_set_iplink(udp_assoc_t *, service_id_t);
    50 extern int udp_assoc_send(udp_assoc_t *, inet_ep_t *, udp_msg_t *);
    51 extern int udp_assoc_recv(udp_assoc_t *, udp_msg_t **, inet_ep_t *);
     50extern errno_t udp_assoc_send(udp_assoc_t *, inet_ep_t *, udp_msg_t *);
     51extern errno_t udp_assoc_recv(udp_assoc_t *, udp_msg_t **, inet_ep_t *);
    5252extern void udp_assoc_received(inet_ep2_t *, udp_msg_t *);
    5353extern void udp_assoc_reset(udp_assoc_t *);
  • uspace/srv/net/udp/pdu.c

    r36f0738 rb7fd2a0  
    162162
    163163/** Decode incoming PDU */
    164 int udp_pdu_decode(udp_pdu_t *pdu, inet_ep2_t *epp, udp_msg_t **msg)
     164errno_t udp_pdu_decode(udp_pdu_t *pdu, inet_ep2_t *epp, udp_msg_t **msg)
    165165{
    166166        udp_msg_t *nmsg;
     
    209209
    210210/** Encode outgoing PDU */
    211 int udp_pdu_encode(inet_ep2_t *epp, udp_msg_t *msg, udp_pdu_t **pdu)
     211errno_t udp_pdu_encode(inet_ep2_t *epp, udp_msg_t *msg, udp_pdu_t **pdu)
    212212{
    213213        udp_pdu_t *npdu;
  • uspace/srv/net/udp/pdu.h

    r36f0738 rb7fd2a0  
    4242extern udp_pdu_t *udp_pdu_new(void);
    4343extern void udp_pdu_delete(udp_pdu_t *);
    44 extern int udp_pdu_decode(udp_pdu_t *, inet_ep2_t *, udp_msg_t **);
    45 extern int udp_pdu_encode(inet_ep2_t *, udp_msg_t *, udp_pdu_t **);
     44extern errno_t udp_pdu_decode(udp_pdu_t *, inet_ep2_t *, udp_msg_t **);
     45extern errno_t udp_pdu_encode(inet_ep2_t *, udp_msg_t *, udp_pdu_t **);
    4646
    4747#endif
  • uspace/srv/net/udp/service.c

    r36f0738 rb7fd2a0  
    7070 * @return EOK on success, ENOMEM if out of memory
    7171 */
    72 static int udp_cassoc_queue_msg(udp_cassoc_t *cassoc, inet_ep2_t *epp,
     72static errno_t udp_cassoc_queue_msg(udp_cassoc_t *cassoc, inet_ep2_t *epp,
    7373    udp_msg_t *msg)
    7474{
     
    123123 * @return EOK on soccess, ENOMEM if out of memory
    124124 */
    125 static int udp_cassoc_create(udp_client_t *client, udp_assoc_t *assoc,
     125static errno_t udp_cassoc_create(udp_client_t *client, udp_assoc_t *assoc,
    126126    udp_cassoc_t **rcassoc)
    127127{
     
    168168 *         is found.
    169169 */
    170 static int udp_cassoc_get(udp_client_t *client, sysarg_t id,
     170static errno_t udp_cassoc_get(udp_client_t *client, sysarg_t id,
    171171    udp_cassoc_t **rcassoc)
    172172{
     
    207207 * @return EOK on success or an error code
    208208 */
    209 static int udp_assoc_create_impl(udp_client_t *client, inet_ep2_t *epp,
     209static errno_t udp_assoc_create_impl(udp_client_t *client, inet_ep2_t *epp,
    210210    sysarg_t *rassoc_id)
    211211{
    212212        udp_assoc_t *assoc;
    213213        udp_cassoc_t *cassoc;
    214         int rc;
     214        errno_t rc;
    215215
    216216        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_create_impl");
     
    252252 * @return EOK on success, ENOENT if no such association is found
    253253 */
    254 static int udp_assoc_destroy_impl(udp_client_t *client, sysarg_t assoc_id)
     254static errno_t udp_assoc_destroy_impl(udp_client_t *client, sysarg_t assoc_id)
    255255{
    256256        udp_cassoc_t *cassoc;
    257         int rc;
     257        errno_t rc;
    258258
    259259        rc = udp_cassoc_get(client, assoc_id, &cassoc);
     
    278278 * @return EOK on success, ENOENT if no such association is found
    279279 */
    280 static int udp_assoc_set_nolocal_impl(udp_client_t *client, sysarg_t assoc_id)
     280static errno_t udp_assoc_set_nolocal_impl(udp_client_t *client, sysarg_t assoc_id)
    281281{
    282282        udp_cassoc_t *cassoc;
    283         int rc;
     283        errno_t rc;
    284284
    285285        rc = udp_cassoc_get(client, assoc_id, &cassoc);
     
    307307 * @return EOK on success or an error code
    308308 */
    309 static int udp_assoc_send_msg_impl(udp_client_t *client, sysarg_t assoc_id,
     309static errno_t udp_assoc_send_msg_impl(udp_client_t *client, sysarg_t assoc_id,
    310310    inet_ep_t *dest, void *data, size_t size)
    311311{
    312312        udp_msg_t msg;
    313313        udp_cassoc_t *cassoc;
    314         int rc;
     314        errno_t rc;
    315315
    316316        rc = udp_cassoc_get(client, assoc_id, &cassoc);
     
    365365        inet_ep2_t epp;
    366366        sysarg_t assoc_id;
    367         int rc;
     367        errno_t rc;
    368368
    369369        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_create_srv()");
     
    409409{
    410410        sysarg_t assoc_id;
    411         int rc;
     411        errno_t rc;
    412412
    413413        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_destroy_srv()");
     
    430430{
    431431        sysarg_t assoc_id;
    432         int rc;
     432        errno_t rc;
    433433
    434434        log_msg(LOG_DEFAULT, LVL_NOTE, "udp_assoc_set_nolocal_srv()");
     
    455455        sysarg_t assoc_id;
    456456        void *data;
    457         int rc;
     457        errno_t rc;
    458458
    459459        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send_msg_srv()");
     
    552552        udp_crcv_queue_entry_t *enext;
    553553        sysarg_t assoc_id;
    554         int rc;
     554        errno_t rc;
    555555
    556556        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_rmsg_info_srv()");
     
    601601        size_t size;
    602602        size_t off;
    603         int rc;
     603        errno_t rc;
    604604
    605605        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_rmsg_read_srv()");
     
    752752 * @return EOK on success or an error code.
    753753 */
    754 int udp_service_init(void)
    755 {
    756         int rc;
     754errno_t udp_service_init(void)
     755{
     756        errno_t rc;
    757757        service_id_t sid;
    758758
  • uspace/srv/net/udp/service.h

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

    r36f0738 rb7fd2a0  
    4747#define NAME       "udp"
    4848
    49 static int udp_init(void)
     49static errno_t udp_init(void)
    5050{
    51         int rc;
     51        errno_t rc;
    5252
    5353        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_init()");
     
    7676int main(int argc, char **argv)
    7777{
    78         int rc;
     78        errno_t rc;
    7979
    8080        printf(NAME ": UDP (User Datagram Protocol) service\n");
  • uspace/srv/net/udp/udp_inet.c

    r36f0738 rb7fd2a0  
    4545#include "udp_type.h"
    4646
    47 static int udp_inet_ev_recv(inet_dgram_t *dgram);
     47static errno_t udp_inet_ev_recv(inet_dgram_t *dgram);
    4848static void udp_received_pdu(udp_pdu_t *pdu);
    4949
     
    5353
    5454/** Received datagram callback */
    55 static int udp_inet_ev_recv(inet_dgram_t *dgram)
     55static errno_t udp_inet_ev_recv(inet_dgram_t *dgram)
    5656{
    5757        udp_pdu_t *pdu;
     
    7777
    7878/** Transmit PDU over network layer. */
    79 int udp_transmit_pdu(udp_pdu_t *pdu)
     79errno_t udp_transmit_pdu(udp_pdu_t *pdu)
    8080{
    81         int rc;
     81        errno_t rc;
    8282        inet_dgram_t dgram;
    8383
     
    119119}
    120120
    121 int udp_inet_init(void)
     121errno_t udp_inet_init(void)
    122122{
    123         int rc;
     123        errno_t rc;
    124124
    125125        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_inet_init()");
  • uspace/srv/net/udp/udp_inet.h

    r36f0738 rb7fd2a0  
    3838#include "udp_type.h"
    3939
    40 extern int udp_inet_init(void);
    41 extern int udp_transmit_pdu(udp_pdu_t *);
     40extern errno_t udp_inet_init(void);
     41extern errno_t udp_transmit_pdu(udp_pdu_t *);
    4242
    4343#endif
Note: See TracChangeset for help on using the changeset viewer.