Changes in / [9ce7eb5:3090715] in mainline


Ignore:
Location:
uspace
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/measured_strings.c

    r9ce7eb5 r3090715  
    4141#include <unistd.h>
    4242#include <errno.h>
    43 #include <err.h>
    4443#include <async.h>
    4544
     
    135134    size_t count)
    136135{
    137         ERROR_DECLARE;
    138 
    139136        size_t *lengths;
    140137        size_t index;
     
    142139        char *next;
    143140        ipc_callid_t callid;
     141        int rc;
    144142
    145143        if ((!strings) || (!data) || (count <= 0))
     
    155153                return EINVAL;
    156154        }
    157         if (ERROR_OCCURRED(async_data_write_finalize(callid, lengths,
    158             length))) {
    159                 free(lengths);
    160                 return ERROR_CODE;
     155        rc = async_data_write_finalize(callid, lengths, length);
     156        if (rc != EOK) {
     157                free(lengths);
     158                return rc;
    161159        }
    162160
     
    187185                                return EINVAL;
    188186                        }
    189                         if (ERROR_OCCURRED(async_data_write_finalize(callid,
    190                             next, lengths[index]))) {
     187                        rc = async_data_write_finalize(callid, next,
     188                            lengths[index]);
     189                        if (rc != EOK) {
    191190                                free(*data);
    192191                                free(*strings);
    193192                                free(lengths);
    194                                 return ERROR_CODE;
     193                                return rc;
    195194                        }
    196195                        (*strings)[index].value = next;
     
    251250int measured_strings_reply(const measured_string_ref strings, size_t count)
    252251{
    253         ERROR_DECLARE;
    254 
    255252        size_t *lengths;
    256253        size_t index;
    257254        size_t length;
    258255        ipc_callid_t callid;
     256        int rc;
    259257
    260258        if ((!strings) || (count <= 0))
     
    270268                return EINVAL;
    271269        }
    272         if (ERROR_OCCURRED(async_data_read_finalize(callid, lengths, length))) {
    273                 free(lengths);
    274                 return ERROR_CODE;
     270        rc = async_data_read_finalize(callid, lengths, length);
     271        if (rc != EOK) {
     272                free(lengths);
     273                return rc;
    275274        }
    276275        free(lengths);
     
    282281                                return EINVAL;
    283282                        }
    284                         ERROR_PROPAGATE(async_data_read_finalize(callid,
    285                             strings[index].value, strings[index].length));
     283                        rc = async_data_read_finalize(callid,
     284                            strings[index].value, strings[index].length);
     285                        if (rc != EOK)
     286                                return rc;
    286287                }
    287288        }
     
    313314    size_t count)
    314315{
    315         ERROR_DECLARE;
    316 
    317316        size_t *lengths;
    318317        size_t index;
    319318        char *next;
     319        int rc;
    320320
    321321        if ((phone < 0) || (!strings) || (!data) || (count <= 0))
     
    326326                return ENOMEM;
    327327
    328         if (ERROR_OCCURRED(async_data_read_start(phone, lengths,
    329             sizeof(size_t) * (count + 1)))) {
    330                 free(lengths);
    331                 return ERROR_CODE;
     328        rc = async_data_read_start(phone, lengths,
     329            sizeof(size_t) * (count + 1));
     330        if (rc != EOK) {
     331                free(lengths);
     332                return rc;
    332333        }
    333334
     
    350351                (*strings)[index].length = lengths[index];
    351352                if (lengths[index] > 0) {
    352                         if (ERROR_OCCURRED(async_data_read_start(phone, next,
    353                             lengths[index]))) {
     353                        rc = async_data_read_start(phone, next, lengths[index]);
     354                        if (rc != EOK) {
    354355                                free(lengths);
    355356                                free(data);
    356357                                free(strings);
    357                                 return ERROR_CODE;
     358                                return rc;
    358359                        }
    359360                        (*strings)[index].value = next;
     
    387388    size_t count)
    388389{
    389         ERROR_DECLARE;
    390 
    391390        size_t *lengths;
    392391        size_t index;
     392        int rc;
    393393
    394394        if ((phone < 0) || (!strings) || (count <= 0))
     
    399399                return ENOMEM;
    400400
    401         if (ERROR_OCCURRED(async_data_write_start(phone, lengths,
    402             sizeof(size_t) * (count + 1)))) {
    403                 free(lengths);
    404                 return ERROR_CODE;
     401        rc = async_data_write_start(phone, lengths,
     402            sizeof(size_t) * (count + 1));
     403        if (rc != EOK) {
     404                free(lengths);
     405                return rc;
    405406        }
    406407
     
    409410        for (index = 0; index < count; index++) {
    410411                if (strings[index].length > 0) {
    411                         ERROR_PROPAGATE(async_data_write_start(phone,
    412                             strings[index].value, strings[index].length));
     412                        rc = async_data_write_start(phone, strings[index].value,
     413                            strings[index].length);
     414                        if (rc != EOK)
     415                                return rc;
    413416                }
    414417        }
  • uspace/lib/c/include/adt/generic_char_map.h

    r9ce7eb5 r3090715  
    4040#include <unistd.h>
    4141#include <errno.h>
    42 #include <err.h>
    4342
    4443#include <adt/char_map.h>
     
    8584             type *value) \
    8685        { \
    87                 ERROR_DECLARE; \
     86                int rc; \
    8887                int index; \
    8988                if (!name##_is_valid(map)) \
     
    9291                if (index < 0) \
    9392                        return index; \
    94                 if (ERROR_OCCURRED(char_map_add(&map->names, name, length, \
    95                     index))) { \
     93                rc = char_map_add(&map->names, name, length, index); \
     94                if (rc != EOK) { \
    9695                        name##_items_exclude_index(&map->values, index); \
    97                         return ERROR_CODE; \
     96                        return rc; \
    9897                } \
    9998                return EOK; \
     
    141140        int name##_initialize(name##_ref map) \
    142141        { \
    143                 ERROR_DECLARE; \
     142                int rc; \
    144143                if (!map) \
    145144                        return EINVAL; \
    146                 ERROR_PROPAGATE(char_map_initialize(&map->names)); \
    147                 if (ERROR_OCCURRED(name##_items_initialize(&map->values))) { \
     145                rc = char_map_initialize(&map->names); \
     146                if (rc != EOK) \
     147                        return rc; \
     148                rc = name##_items_initialize(&map->values); \
     149                if (rc != EOK) { \
    148150                        char_map_destroy(&map->names); \
    149                         return ERROR_CODE; \
     151                        return rc; \
    150152                } \
    151153                map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \
  • uspace/lib/c/include/err.h

    r9ce7eb5 r3090715  
    3737
    3838#include <stdio.h>
    39 #include <errno.h>
    40 
    41 #ifdef CONFIG_DEBUG
    42 #include <str_error.h>
    43 #endif
    4439
    4540#define errx(status, fmt, ...) { \
     
    4843}
    4944
    50 
    51 /** An actual stored error code.  */
    52 #define ERROR_CODE  error_check_return_value
    53 
    54 /** An error processing routines declaration.
    55  *
    56  * This has to be declared in the block where the error processing
    57  * is desired.
    58  */
    59 #define ERROR_DECLARE  int ERROR_CODE
    60 
    61 /** Store the value as an error code and checks if an error occurred.
    62  *
    63  * @param[in] value     The value to be checked. May be a function call.
    64  * @return              False if the value indicates success (EOK).
    65  * @return              True otherwise.
    66  */
    67 #ifdef CONFIG_DEBUG
    68 
    69 #define ERROR_OCCURRED(value) \
    70         (((ERROR_CODE = (value)) != EOK) && \
    71         ({ \
    72                 fprintf(stderr, "libsocket error at %s:%d (%s)\n", \
    73                 __FILE__, __LINE__, str_error(ERROR_CODE)); \
    74                 1; \
    75         }))
    76 
    77 #else
    78 
    79 #define ERROR_OCCURRED(value)   ((ERROR_CODE = (value)) != EOK)
    80 
    81 #endif
    82 
    83 #define ERROR_NONE(value)       !ERROR_OCCURRED((value))
    84 
    85 /** Error propagation
    86  *
    87  * Check if an error occurred and immediately exit the actual
    88  * function returning the error code.
    89  *
    90  * @param[in] value     The value to be checked. May be a function call.
    91  *
    92  */
    93 
    94 #define ERROR_PROPAGATE(value) \
    95         if (ERROR_OCCURRED(value)) \
    96                 return ERROR_CODE
    97 
    9845#endif
    9946
    10047/** @}
    10148 */
     49
  • uspace/lib/net/adt/module_map.c

    r9ce7eb5 r3090715  
    3838#include <task.h>
    3939#include <unistd.h>
    40 #include <err.h>
     40#include <errno.h>
    4141
    4242#include <ipc/services.h>
     
    6767    connect_module_t connect_module)
    6868{
    69         ERROR_DECLARE;
    70 
    7169        module_ref tmp_module;
     70        int rc;
    7271
    7372        tmp_module = (module_ref) malloc(sizeof(module_t));
     
    8382        tmp_module->connect_module = connect_module;
    8483
    85         if (ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0,
    86             tmp_module))) {
     84        rc = modules_add(modules, tmp_module->name, 0, tmp_module);
     85        if (rc != EOK) {
    8786                free(tmp_module);
    88                 return ERROR_CODE;
     87                return rc;
    8988        }
    9089        if (module)
  • uspace/lib/net/generic/packet_remote.c

    r9ce7eb5 r3090715  
    3838#include <async.h>
    3939#include <errno.h>
    40 #include <err.h>
    4140#include <ipc/ipc.h>
    4241#include <ipc/packet.h>
     
    6766packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size)
    6867{
    69         ERROR_DECLARE;
    70        
    7168        ipc_call_t answer;
    72         aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
     69        aid_t message;
     70        int rc;
     71       
     72        message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
    7373
    7474        *packet = (packet_t) as_get_mappable_page(size);
    75         if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) ||
    76             ERROR_OCCURRED(pm_add(*packet))) {
     75        rc = async_share_in_start_0_0(phone, *packet, size);
     76        if (rc != EOK) {
    7777                munmap(*packet, size);
    7878                async_wait_for(message, NULL);
    79                 return ERROR_CODE;
     79                return rc;
     80        }
     81        rc = pm_add(*packet);
     82        if (rc != EOK) {
     83                munmap(*packet, size);
     84                async_wait_for(message, NULL);
     85                return rc;
    8086        }
    8187       
     
    103109int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id)
    104110{
    105         ERROR_DECLARE;
     111        int rc;
    106112       
    107113        if (!packet)
     
    112118                ipcarg_t size;
    113119               
    114                 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE,
    115                     packet_id, &size));
    116                 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
     120                rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id,
     121                    &size);
     122                if (rc != EOK)
     123                        return rc;
     124                rc = packet_return(phone, packet, packet_id, size);
     125                if (rc != EOK)
     126                        return rc;
    117127        }
    118128        if ((*packet)->next) {
     
    141151    size_t max_prefix, size_t max_suffix)
    142152{
    143         ERROR_DECLARE;
    144        
    145153        ipcarg_t packet_id;
    146154        ipcarg_t size;
    147        
    148         if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4,
    149             max_content, addr_len, max_prefix, max_suffix, &packet_id, &size)))
     155        int rc;
     156       
     157        rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len,
     158            max_prefix, max_suffix, &packet_id, &size);
     159        if (rc != EOK)
    150160                return NULL;
    151161       
     
    153163        packet_t packet = pm_find(packet_id);
    154164        if (!packet) {
    155                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
    156                     size)))
     165                rc = packet_return(phone, &packet, packet_id, size);
     166                if (rc != EOK)
    157167                        return NULL;
    158168        }
     
    172182packet_t packet_get_1_remote(int phone, size_t content)
    173183{
    174         ERROR_DECLARE;
    175        
    176184        ipcarg_t packet_id;
    177185        ipcarg_t size;
    178        
    179         if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content,
    180             &packet_id, &size)))
     186        int rc;
     187       
     188        rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id,
     189            &size);
     190        if (rc != EOK)
    181191                return NULL;
    182192       
    183193        packet_t packet = pm_find(packet_id);
    184194        if (!packet) {
    185                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
    186                     size)))
     195                rc = packet_return(phone, &packet, packet_id, size);
     196                if (rc != EOK)
    187197                        return NULL;
    188198        }
  • uspace/lib/net/netif/netif_local.c

    r9ce7eb5 r3090715  
    4343#include <ipc/services.h>
    4444#include <ipc/netif.h>
    45 #include <err.h>
     45#include <errno.h>
    4646
    4747#include <generic.h>
     
    113113int netif_start_req_local(int netif_phone, device_id_t device_id)
    114114{
    115         ERROR_DECLARE;
     115        int rc;
    116116       
    117117        fibril_rwlock_write_lock(&netif_globals.lock);
    118118       
    119119        netif_device_t *device;
    120         if (ERROR_OCCURRED(find_device(device_id, &device))) {
     120        rc = find_device(device_id, &device);
     121        if (rc != EOK) {
    121122                fibril_rwlock_write_unlock(&netif_globals.lock);
    122                 return ERROR_CODE;
     123                return rc;
    123124        }
    124125       
     
    148149int netif_stop_req_local(int netif_phone, device_id_t device_id)
    149150{
    150         ERROR_DECLARE;
     151        int rc;
    151152       
    152153        fibril_rwlock_write_lock(&netif_globals.lock);
    153154       
    154155        netif_device_t *device;
    155         if (ERROR_OCCURRED(find_device(device_id, &device))) {
     156        rc = find_device(device_id, &device);
     157        if (rc != EOK) {
    156158                fibril_rwlock_write_unlock(&netif_globals.lock);
    157                 return ERROR_CODE;
     159                return rc;
    158160        }
    159161       
     
    203205    measured_string_ref *address, char **data)
    204206{
    205         ERROR_DECLARE;
     207        int rc;
    206208       
    207209        if (!address || !data)
     
    211213       
    212214        measured_string_t translation;
    213         if (!ERROR_OCCURRED(netif_get_addr_message(device_id, &translation))) {
     215        rc = netif_get_addr_message(device_id, &translation);
     216        if (rc == EOK) {
    214217                *address = measured_string_copy(&translation);
    215                 ERROR_CODE = (*address) ? EOK : ENOMEM;
     218                rc = (*address) ? EOK : ENOMEM;
    216219        }
    217220       
     
    220223        *data = (**address).value;
    221224       
    222         return ERROR_CODE;
     225        return rc;
    223226}
    224227
     
    264267int netif_init_module(async_client_conn_t client_connection)
    265268{
    266         ERROR_DECLARE;
     269        int rc;
    267270       
    268271        async_set_client_connection(client_connection);
     
    271274        netif_device_map_initialize(&netif_globals.device_map);
    272275       
    273         ERROR_PROPAGATE(pm_init());
     276        rc = pm_init();
     277        if (rc != EOK)
     278                return rc;
    274279       
    275280        fibril_rwlock_initialize(&netif_globals.lock);
    276         if (ERROR_OCCURRED(netif_initialize())) {
     281       
     282        rc = netif_initialize();
     283        if (rc != EOK) {
    277284                pm_destroy();
    278                 return ERROR_CODE;
     285                return rc;
    279286        }
    280287       
     
    317324static int register_message(const char *name, device_id_t device_id, int phone)
    318325{
    319         ERROR_DECLARE;
    320        
    321326        netif_device_t *device;
    322         ERROR_PROPAGATE(find_device(device_id, &device));
    323         if(device->nil_phone > 0)
     327        int rc;
     328       
     329        rc = find_device(device_id, &device);
     330        if (rc != EOK)
     331                return rc;
     332       
     333        if (device->nil_phone > 0)
    324334                return ELIMIT;
    325335       
     
    349359    ipc_call_t *call, ipc_call_t *answer, int *answer_count)
    350360{
    351         ERROR_DECLARE;
    352        
    353361        size_t length;
    354362        device_stats_t stats;
    355363        packet_t packet;
    356364        measured_string_t address;
     365        int rc;
    357366       
    358367        *answer_count = 0;
     
    367376        case IPC_M_CONNECT_TO_ME:
    368377                fibril_rwlock_write_lock(&netif_globals.lock);
    369                 ERROR_CODE = register_message(name, IPC_GET_DEVICE(call),
     378                rc = register_message(name, IPC_GET_DEVICE(call),
    370379                    IPC_GET_PHONE(call));
    371380                fibril_rwlock_write_unlock(&netif_globals.lock);
    372                 return ERROR_CODE;
     381                return rc;
    373382               
    374383        case NET_NETIF_SEND:
    375                 ERROR_PROPAGATE(packet_translate_remote(netif_globals.net_phone,
    376                     &packet, IPC_GET_PACKET(call)));
     384                rc = packet_translate_remote(netif_globals.net_phone, &packet,
     385                    IPC_GET_PACKET(call));
     386                if (rc != EOK)
     387                        return rc;
    377388                return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet,
    378389                    IPC_GET_SENDER(call));
    379                    
     390               
    380391        case NET_NETIF_START:
    381392                return netif_start_req_local(0, IPC_GET_DEVICE(call));
     
    384395                fibril_rwlock_read_lock(&netif_globals.lock);
    385396
    386                 if (ERROR_OCCURRED(async_data_read_receive(&callid, &length))) {
     397                rc = async_data_read_receive(&callid, &length);
     398                if (rc != EOK) {
    387399                        fibril_rwlock_read_unlock(&netif_globals.lock);
    388                         return ERROR_CODE;
     400                        return rc;
    389401                }
    390402                if (length < sizeof(device_stats_t)) {
     
    393405                }
    394406
    395                 if (ERROR_NONE(netif_get_device_stats(IPC_GET_DEVICE(call),
    396                     &stats))) {
    397                         ERROR_CODE = async_data_read_finalize(callid, &stats,
     407                rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats);
     408                if (rc == EOK) {
     409                        rc = async_data_read_finalize(callid, &stats,
    398410                            sizeof(device_stats_t));
    399411                }
    400412
    401413                fibril_rwlock_read_unlock(&netif_globals.lock);
    402                 return ERROR_CODE;
     414                return rc;
    403415
    404416        case NET_NETIF_STOP:
     
    407419        case NET_NETIF_GET_ADDR:
    408420                fibril_rwlock_read_lock(&netif_globals.lock);
    409                 if (ERROR_NONE(netif_get_addr_message(IPC_GET_DEVICE(call),
    410                     &address)))
    411                         ERROR_CODE = measured_strings_reply(&address, 1);
     421                rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address);
     422                if (rc == EOK)
     423                        rc = measured_strings_reply(&address, 1);
    412424                fibril_rwlock_read_unlock(&netif_globals.lock);
    413                 return ERROR_CODE;
     425                return rc;
    414426        }
    415427       
     
    431443int netif_module_start_standalone(async_client_conn_t client_connection)
    432444{
    433         ERROR_DECLARE;
    434        
    435         ERROR_PROPAGATE(netif_init_module(client_connection));
     445        int rc;
     446       
     447        rc = netif_init_module(client_connection);
     448        if (rc != EOK)
     449                return rc;
    436450       
    437451        async_manager();
  • uspace/lib/net/tl/socket_core.c

    r9ce7eb5 r3090715  
    4848#include <stdlib.h>
    4949#include <errno.h>
    50 #include <err.h>
    5150
    5251#include <adt/dynamic_fifo.h>
     
    164163    const char *key, size_t key_length)
    165164{
    166         ERROR_DECLARE;
    167 
    168165        socket_core_ref *socket_ref;
     166        int rc;
    169167
    170168        // create a wrapper
     
    175173        *socket_ref = socket;
    176174        // add the wrapper
    177         if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key,
    178             key_length, socket_ref))) {
     175        rc = socket_port_map_add(&socket_port->map, key, key_length,
     176            socket_ref);
     177        if (rc != EOK) {
    179178                free(socket_ref);
    180                 return ERROR_CODE;
     179                return rc;
    181180        }
    182181       
     
    204203    int port)
    205204{
    206         ERROR_DECLARE;
    207 
    208205        socket_port_ref socket_port;
     206        int rc;
    209207
    210208        // create a wrapper
     
    214212
    215213        socket_port->count = 0;
    216         if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) ||
    217             ERROR_OCCURRED(socket_port_add_core(socket_port, socket,
    218             SOCKET_MAP_KEY_LISTENING, 0))) {
    219                 socket_port_map_destroy(&socket_port->map);
    220                 free(socket_port);
    221                 return ERROR_CODE;
    222         }
     214        rc = socket_port_map_initialize(&socket_port->map);
     215        if (rc != EOK)
     216                goto fail;
     217       
     218        rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING,
     219            0);
     220        if (rc != EOK)
     221                goto fail;
    223222       
    224223        // register the incomming port
    225         ERROR_CODE = socket_ports_add(global_sockets, port, socket_port);
    226         if (ERROR_CODE < 0) {
    227                 socket_port_map_destroy(&socket_port->map);
    228                 free(socket_port);
    229                 return ERROR_CODE;
    230         }
     224        rc = socket_ports_add(global_sockets, port, socket_port);
     225        if (rc < 0)
     226                goto fail;
    231227       
    232228        socket->port = port;
    233229        return EOK;
     230
     231fail:
     232        socket_port_map_destroy(&socket_port->map);
     233        free(socket_port);
     234        return rc;
     235       
    234236}
    235237
     
    416418    void *specific_data, int *socket_id)
    417419{
    418         ERROR_DECLARE;
    419 
    420420        socket_core_ref socket;
    421         int res;
    422421        int positive;
     422        int rc;
    423423
    424424        if (!socket_id)
     
    447447        socket->key_length = 0;
    448448        socket->specific_data = specific_data;
    449         if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received,
    450             SOCKET_INITIAL_RECEIVED_SIZE))) {
     449        rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE);
     450        if (rc != EOK) {
    451451                free(socket);
    452                 return ERROR_CODE;
    453         }
    454         if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted,
    455             SOCKET_INITIAL_ACCEPTED_SIZE))) {
     452                return rc;
     453        }
     454       
     455        rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);
     456        if (rc != EOK) {
    456457                dyn_fifo_destroy(&socket->received);
    457458                free(socket);
    458                 return ERROR_CODE;
     459                return rc;
    459460        }
    460461        socket->socket_id = *socket_id;
    461         res = socket_cores_add(local_sockets, socket->socket_id, socket);
    462         if (res < 0) {
     462        rc = socket_cores_add(local_sockets, socket->socket_id, socket);
     463        if (rc < 0) {
    463464                dyn_fifo_destroy(&socket->received);
    464465                dyn_fifo_destroy(&socket->accepted);
    465466                free(socket);
    466                 return res;
     467                return rc;
    467468        }
    468469       
     
    523524int socket_reply_packets(packet_t packet, size_t *length)
    524525{
    525         ERROR_DECLARE;
    526 
    527526        packet_t next_packet;
    528527        size_t fragments;
    529528        size_t *lengths;
    530529        size_t index;
     530        int rc;
    531531
    532532        if (!length)
     
    536536        if (!next_packet) {
    537537                // write all if only one fragment
    538                 ERROR_PROPAGATE(data_reply(packet_get_data(packet),
    539                     packet_get_data_length(packet)));
     538                rc = data_reply(packet_get_data(packet),
     539                    packet_get_data_length(packet));
     540                if (rc != EOK)
     541                        return rc;
    540542                // store the total length
    541543                *length = packet_get_data_length(packet);
     
    564566               
    565567                // write the fragment lengths
    566                 if (ERROR_OCCURRED(data_reply(lengths,
    567                     sizeof(int) * (fragments + 1)))) {
     568                rc = data_reply(lengths, sizeof(int) * (fragments + 1));
     569                if (rc != EOK) {
    568570                        free(lengths);
    569                         return ERROR_CODE;
     571                        return rc;
    570572                }
    571573                next_packet = packet;
     
    573575                // write the fragments
    574576                for (index = 0; index < fragments; ++index) {
    575                         ERROR_CODE = data_reply(packet_get_data(next_packet),
     577                        rc = data_reply(packet_get_data(next_packet),
    576578                            lengths[index]);
    577                         if (ERROR_OCCURRED(ERROR_CODE)) {
     579                        if (rc != EOK) {
    578580                                free(lengths);
    579                                 return ERROR_CODE;
     581                                return rc;
    580582                        }
    581583                        next_packet = pq_next(next_packet);
     
    680682    socket_core_ref socket, const char *key, size_t key_length)
    681683{
    682         ERROR_DECLARE;
    683 
    684684        socket_port_ref socket_port;
     685        int rc;
    685686
    686687        // find ports
     
    690691       
    691692        // add the socket
    692         ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key,
    693             key_length));
     693        rc = socket_port_add_core(socket_port, socket, key, key_length);
     694        if (rc != EOK)
     695                return rc;
    694696       
    695697        socket->port = port;
  • uspace/lib/net/tl/tl_common.c

    r9ce7eb5 r3090715  
    5454#include <ipc/services.h>
    5555#include <errno.h>
    56 #include <err.h>
    5756
    5857DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t);
     
    124123    packet_dimension_ref *packet_dimension)
    125124{
    126         ERROR_DECLARE;
     125        int rc;
    127126       
    128127        if (!packet_dimension)
     
    137136                        return ENOMEM;
    138137               
    139                 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,
    140                     *packet_dimension))) {
     138                rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension);
     139                if (rc != EOK) {
    141140                        free(*packet_dimension);
    142                         return ERROR_CODE;
     141                        return rc;
    143142                }
    144143               
    145                 ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id,
     144                rc = packet_dimensions_add(packet_dimensions, device_id,
    146145                    *packet_dimension);
    147                 if (ERROR_CODE < 0) {
     146                if (rc < 0) {
    148147                        free(*packet_dimension);
    149                         return ERROR_CODE;
     148                        return rc;
    150149                }
    151150        }
     
    292291    socklen_t addrlen)
    293292{
    294         ERROR_DECLARE;
    295 
    296293        ipc_callid_t callid;
    297294        size_t length;
    298         void * data;
     295        void *data;
     296        int rc;
    299297
    300298        if (!dimension)
     
    319317
    320318        // read the data into the packet
    321         if (ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) ||
    322             // set the packet destination address
    323             ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr,
    324             addrlen))) {
     319        rc = async_data_write_finalize(callid, data, length);
     320        if (rc != EOK) {
    325321                pq_release_remote(packet_phone, packet_get_id(*packet));
    326                 return ERROR_CODE;
     322                return rc;
     323        }
     324       
     325        // set the packet destination address
     326        rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen);
     327        if (rc != EOK) {
     328                pq_release_remote(packet_phone, packet_get_id(*packet));
     329                return rc;
    327330        }
    328331
  • uspace/lib/packet/generic/packet_server.c

    r9ce7eb5 r3090715  
    4242#include <async.h>
    4343#include <errno.h>
    44 #include <err.h>
    4544#include <fibril_synch.h>
    4645#include <unistd.h>
     
    162161    size_t max_content, size_t max_suffix)
    163162{
    164         ERROR_DECLARE;
    165 
    166163        packet_t packet;
     164        int rc;
    167165
    168166        // already locked
     
    177175        packet_init(packet, addr_len, max_prefix, max_content, max_suffix);
    178176        packet->magic_value = PACKET_MAGIC_VALUE;
    179         if (ERROR_OCCURRED(pm_add(packet))) {
     177        rc = pm_add(packet);
     178        if (rc != EOK) {
    180179                munmap(packet, packet->length);
    181180                return NULL;
  • uspace/srv/hw/netif/dp8390/dp8390_module.c

    r9ce7eb5 r3090715  
    158158
    159159int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){
    160         ERROR_DECLARE;
    161 
    162160        netif_device_t * device;
    163161        eth_stat_t * de_stat;
     162        int rc;
    164163
    165164        if(! stats){
    166165                return EBADMEM;
    167166        }
    168         ERROR_PROPAGATE(find_device(device_id, &device));
     167        rc = find_device(device_id, &device);
     168        if (rc != EOK)
     169                return rc;
    169170        de_stat = &((dpeth_t *) device->specific)->de_stat;
    170171        null_device_stats(stats);
     
    185186
    186187int netif_get_addr_message(device_id_t device_id, measured_string_ref address){
    187         ERROR_DECLARE;
    188 
    189         netif_device_t * device;
     188        netif_device_t * device;
     189        int rc;
    190190
    191191        if(! address){
    192192                return EBADMEM;
    193193        }
    194         ERROR_PROPAGATE(find_device(device_id, &device));
     194        rc = find_device(device_id, &device);
     195        if (rc != EOK)
     196                return rc;
    195197        address->value = (char *) (&((dpeth_t *) device->specific)->de_address);
    196198        address->length = CONVERT_SIZE(ether_addr_t, char, 1);
     
    201203
    202204int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){
    203         ERROR_DECLARE;
    204 
    205         netif_device_t * device;
    206         dpeth_t * dep;
     205        netif_device_t * device;
     206        dpeth_t * dep;
     207        int rc;
    207208
    208209        device = (netif_device_t *) malloc(sizeof(netif_device_t));
     
    224225        dep->de_mode = DEM_DISABLED;
    225226        //TODO address?
    226         if(ERROR_OCCURRED(pio_enable((void *) io, DP8390_IO_SIZE, (void **) &dep->de_base_port))
    227                 || ERROR_OCCURRED(do_probe(dep))){
     227        rc = pio_enable((void *) io, DP8390_IO_SIZE, (void **) &dep->de_base_port);
     228        if (rc != EOK) {
    228229                free(dep);
    229230                free(device);
    230                 return ERROR_CODE;
    231         }
    232         if(ERROR_OCCURRED(netif_device_map_add(&netif_globals.device_map, device->device_id, device))){
     231                return rc;
     232        }       
     233        rc = do_probe(dep);
     234        if (rc != EOK) {
    233235                free(dep);
    234236                free(device);
    235                 return ERROR_CODE;
     237                return rc;
     238        }
     239        rc = netif_device_map_add(&netif_globals.device_map, device->device_id, device);
     240        if (rc != EOK){
     241                free(dep);
     242                free(device);
     243                return rc;
    236244        }
    237245        return EOK;
     
    239247
    240248int netif_send_message(device_id_t device_id, packet_t packet, services_t sender){
    241         ERROR_DECLARE;
    242 
    243249        netif_device_t * device;
    244250        dpeth_t * dep;
    245251        packet_t next;
    246 
    247         ERROR_PROPAGATE(find_device(device_id, &device));
     252        int rc;
     253
     254        rc = find_device(device_id, &device);
     255        if (rc != EOK)
     256                return rc;
    248257        if(device->state != NETIF_ACTIVE){
    249258                netif_pq_release(packet_get_id(packet));
     
    263272
    264273int netif_start_message(netif_device_t * device){
    265         ERROR_DECLARE;
    266 
    267         dpeth_t * dep;
     274        dpeth_t * dep;
     275        int rc;
    268276
    269277        if(device->state != NETIF_ACTIVE){
     
    271279                dp8390_cmds[0].addr = (void *) (uintptr_t) (dep->de_dp8390_port + DP_ISR);
    272280                dp8390_cmds[2].addr = dp8390_cmds[0].addr;
    273                 ERROR_PROPAGATE(ipc_register_irq(dep->de_irq, device->device_id, device->device_id, &dp8390_code));
    274                 if(ERROR_OCCURRED(do_init(dep, DL_BROAD_REQ))){
     281                rc = ipc_register_irq(dep->de_irq, device->device_id, device->device_id, &dp8390_code);
     282                if (rc != EOK)
     283                        return rc;
     284                rc = do_init(dep, DL_BROAD_REQ);
     285                if (rc != EOK) {
    275286                        ipc_unregister_irq(dep->de_irq, device->device_id);
    276                         return ERROR_CODE;
     287                        return rc;
    277288                }
    278289                return change_state(device, NETIF_ACTIVE);
     
    350361int main(int argc, char *argv[])
    351362{
    352         ERROR_DECLARE;
     363        int rc;
    353364       
    354365        /* Start the module */
    355         if (ERROR_OCCURRED(netif_module_start(netif_client_connection)))
    356                 return ERROR_CODE;
    357        
    358         return EOK;
     366        rc = netif_module_start(netif_client_connection);
     367        return rc;
    359368}
    360369
Note: See TracChangeset for help on using the changeset viewer.