Changeset 4ef32e0c in mainline


Ignore:
Timestamp:
2010-11-03T21:14:50Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a852181
Parents:
10b229fa
Message:

Get rid of the ERROR_CODE madness in eth.

Location:
uspace/srv/net/nil/eth
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/nil/eth/eth.c

    r10b229fa r4ef32e0c  
    4242#include <byteorder.h>
    4343#include <str.h>
    44 #include <err.h>
     44#include <errno.h>
    4545
    4646#include <ipc/ipc.h>
     
    196196int nil_initialize(int net_phone)
    197197{
    198         ERROR_DECLARE;
     198        int rc;
    199199
    200200        fibril_rwlock_initialize(&eth_globals.devices_lock);
     
    208208            CONVERT_SIZE(uint8_t, char, ETH_ADDR));
    209209        if (!eth_globals.broadcast_addr) {
    210                 ERROR_CODE = ENOMEM;
     210                rc = ENOMEM;
    211211                goto out;
    212212        }
    213         if (ERROR_OCCURRED(eth_devices_initialize(&eth_globals.devices))) {
     213        rc = eth_devices_initialize(&eth_globals.devices);
     214        if (rc != EOK) {
    214215                free(eth_globals.broadcast_addr);
    215216                goto out;
    216217        }
    217         if (ERROR_OCCURRED(eth_protos_initialize(&eth_globals.protos))) {
     218        rc = eth_protos_initialize(&eth_globals.protos);
     219        if (rc != EOK) {
    218220                free(eth_globals.broadcast_addr);
    219221                eth_devices_destroy(&eth_globals.devices);
     
    223225        fibril_rwlock_write_unlock(&eth_globals.devices_lock);
    224226       
    225         return ERROR_CODE;
     227        return rc;
    226228}
    227229
     
    234236static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall)
    235237{
    236         ERROR_DECLARE;
    237 
    238238        packet_t packet;
     239        int rc;
    239240
    240241        while (true) {
     
    246247                        break;
    247248                case NET_NIL_RECEIVED:
    248                         if (ERROR_NONE(packet_translate_remote(
    249                             eth_globals.net_phone, &packet,
    250                             IPC_GET_PACKET(icall)))) {
    251                                 ERROR_CODE = nil_received_msg_local(0,
     249                        rc = packet_translate_remote(eth_globals.net_phone,
     250                            &packet, IPC_GET_PACKET(icall));
     251                        if (rc == EOK) {
     252                                rc = nil_received_msg_local(0,
    252253                                    IPC_GET_DEVICE(icall), packet, 0);
    253254                        }
    254                         ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);
     255                        ipc_answer_0(iid, (ipcarg_t) rc);
    255256                        break;
    256257                default:
     
    282283eth_device_message(device_id_t device_id, services_t service, size_t mtu)
    283284{
    284         ERROR_DECLARE;
    285 
    286285        eth_device_ref device;
    287286        int index;
     
    300299        char *data;
    301300        eth_proto_ref proto;
     301        int rc;
    302302
    303303        fibril_rwlock_write_lock(&eth_globals.devices_lock);
     
    351351
    352352        configuration = &names[0];
    353         if (ERROR_OCCURRED(net_get_device_conf_req(eth_globals.net_phone,
    354             device->device_id, &configuration, count, &data))) {
     353        rc = net_get_device_conf_req(eth_globals.net_phone, device->device_id,
     354            &configuration, count, &data);
     355        if (rc != EOK) {
    355356                fibril_rwlock_write_unlock(&eth_globals.devices_lock);
    356357                free(device);
    357                 return ERROR_CODE;
     358                return rc;
    358359        }
    359360        if (configuration) {
     
    387388       
    388389        // get hardware address
    389         if (ERROR_OCCURRED(netif_get_addr_req(device->phone, device->device_id,
    390             &device->addr, &device->addr_data))) {
     390        rc = netif_get_addr_req(device->phone, device->device_id, &device->addr,
     391            &device->addr_data);
     392        if (rc != EOK) {
    391393                fibril_rwlock_write_unlock(&eth_globals.devices_lock);
    392394                free(device);
    393                 return ERROR_CODE;
     395                return rc;
    394396        }
    395397       
     
    429431static eth_proto_ref eth_process_packet(int flags, packet_t packet)
    430432{
    431         ERROR_DECLARE;
    432 
    433433        eth_header_snap_ref header;
    434434        size_t length;
     
    437437        size_t suffix;
    438438        eth_fcs_ref fcs;
    439         uint8_t * data;
     439        uint8_t *data;
     440        int rc;
    440441
    441442        length = packet_get_data_length(packet);
     
    488489       
    489490        if (IS_DUMMY(flags)) {
    490                 if ((~compute_crc32(~0U, data, length * 8)) != ntohl(*fcs))
     491                if (~compute_crc32(~0U, data, length * 8) != ntohl(*fcs))
    491492                        return NULL;
    492493                suffix += sizeof(eth_fcs_t);
    493494        }
    494495       
    495         if (ERROR_OCCURRED(packet_set_addr(packet,
    496             header->header.source_address, header->header.destination_address,
    497             ETH_ADDR)) || ERROR_OCCURRED(packet_trim(packet, prefix, suffix))) {
     496        rc = packet_set_addr(packet, header->header.source_address,
     497            header->header.destination_address, ETH_ADDR);
     498        if (rc != EOK)
    498499                return NULL;
    499         }
     500
     501        rc = packet_trim(packet, prefix, suffix);
     502        if (rc != EOK)
     503                return NULL;
    500504       
    501505        return eth_protos_find(&eth_globals.protos, type);
     
    781785eth_send_message(device_id_t device_id, packet_t packet, services_t sender)
    782786{
    783         ERROR_DECLARE;
    784 
    785787        eth_device_ref device;
    786788        packet_t next;
    787789        packet_t tmp;
    788790        int ethertype;
     791        int rc;
    789792
    790793        ethertype = htons(protocol_map(SERVICE_ETHERNET, sender));
     
    804807        next = packet;
    805808        do {
    806                 if (ERROR_OCCURRED(eth_prepare_packet(device->flags, next,
    807                     (uint8_t *) device->addr->value, ethertype, device->mtu))) {
     809                rc = eth_prepare_packet(device->flags, next,
     810                    (uint8_t *) device->addr->value, ethertype, device->mtu);
     811                if (rc != EOK) {
    808812                        // release invalid packet
    809813                        tmp = pq_detach(next);
     
    832836    ipc_call_t *answer, int *answer_count)
    833837{
    834         ERROR_DECLARE;
    835        
    836838        measured_string_ref address;
    837839        packet_t packet;
     
    840842        size_t suffix;
    841843        size_t content;
     844        int rc;
    842845       
    843846        *answer_count = 0;
     
    850853                    IPC_GET_SERVICE(call), IPC_GET_MTU(call));
    851854        case NET_NIL_SEND:
    852                 ERROR_PROPAGATE(packet_translate_remote(eth_globals.net_phone,
    853                     &packet, IPC_GET_PACKET(call)));
     855                rc = packet_translate_remote(eth_globals.net_phone, &packet,
     856                    IPC_GET_PACKET(call));
     857                if (rc != EOK)
     858                        return rc;
    854859                return eth_send_message(IPC_GET_DEVICE(call), packet,
    855860                    IPC_GET_SERVICE(call));
    856861        case NET_NIL_PACKET_SPACE:
    857                 ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call),
    858                     &addrlen, &prefix, &content, &suffix));
     862                rc = eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen,
     863                    &prefix, &content, &suffix);
     864                if (rc != EOK)
     865                        return rc;
    859866                IPC_SET_ADDR(answer, addrlen);
    860867                IPC_SET_PREFIX(answer, prefix);
     
    864871                return EOK;
    865872        case NET_NIL_ADDR:
    866                 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call),
    867                     ETH_LOCAL_ADDR, &address));
     873                rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR,
     874                    &address);
     875                if (rc != EOK)
     876                        return rc;
    868877                return measured_strings_reply(address, 1);
    869878        case NET_NIL_BROADCAST_ADDR:
    870                 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call),
    871                     ETH_BROADCAST_ADDR, &address));
     879                rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR,
     880                    &address);
     881                if (rc != EOK)
     882                        return EOK;
    872883                return measured_strings_reply(address, 1);
    873884        case IPC_M_CONNECT_TO_ME:
     
    923934int main(int argc, char *argv[])
    924935{
    925         ERROR_DECLARE;
     936        int rc;
    926937       
    927938        /* Start the module */
    928         ERROR_PROPAGATE(nil_module_start_standalone(nil_client_connection));
    929         return EOK;
     939        rc = nil_module_start_standalone(nil_client_connection);
     940        return rc;
    930941}
    931942
  • uspace/srv/net/nil/eth/eth_module.c

    r10b229fa r4ef32e0c  
    4040#include <async.h>
    4141#include <stdio.h>
    42 #include <err.h>
     42#include <errno.h>
    4343
    4444#include <ipc/ipc.h>
     
    5252int nil_module_start_standalone(async_client_conn_t client_connection)
    5353{
    54         ERROR_DECLARE;
     54        ipcarg_t phonehash;
     55        int rc;
    5556       
    5657        async_set_client_connection(client_connection);
    5758        int net_phone = net_connect_module();
    58         ERROR_PROPAGATE(pm_init());
     59
     60        rc = pm_init();
     61        if (rc != EOK)
     62                return rc;
    5963       
    60         ipcarg_t phonehash;
    61         if (ERROR_OCCURRED(nil_initialize(net_phone)) ||
    62             ERROR_OCCURRED(REGISTER_ME(SERVICE_ETHERNET, &phonehash))) {
     64        rc = nil_initialize(net_phone);
     65        if (rc != EOK) {
    6366                pm_destroy();
    64                 return ERROR_CODE;
     67                return rc;
     68        }
     69
     70        rc = REGISTER_ME(SERVICE_ETHERNET, &phonehash);
     71        if (rc != EOK) {
     72                pm_destroy();
     73                return rc;
    6574        }
    6675       
Note: See TracChangeset for help on using the changeset viewer.