Changeset a35b458 in mainline for uspace/srv/net/ethip/ethip_nic.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (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:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/ethip/ethip_nic.c

    r3061bc1 ra35b458  
    112112                return NULL;
    113113        }
    114        
     114
    115115        link_initialize(&nic->link);
    116116        list_initialize(&nic->addr_list);
    117        
     117
    118118        return nic;
    119119}
     
    127127                return NULL;
    128128        }
    129        
     129
    130130        link_initialize(&laddr->link);
    131131        laddr->addr = *addr;
    132        
     132
    133133        return laddr;
    134134}
     
    138138        if (nic->svc_name != NULL)
    139139                free(nic->svc_name);
    140        
     140
    141141        free(nic);
    142142}
     
    151151        bool in_list = false;
    152152        nic_address_t nic_address;
    153        
     153
    154154        log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_open()");
    155155        ethip_nic_t *nic = ethip_nic_new();
    156156        if (nic == NULL)
    157157                return ENOMEM;
    158        
     158
    159159        errno_t rc = loc_service_get_name(sid, &nic->svc_name);
    160160        if (rc != EOK) {
     
    162162                goto error;
    163163        }
    164        
     164
    165165        nic->sess = loc_service_connect(sid, INTERFACE_DDF, 0);
    166166        if (nic->sess == NULL) {
     
    168168                goto error;
    169169        }
    170        
     170
    171171        nic->svc_id = sid;
    172        
     172
    173173        rc = nic_callback_create(nic->sess, ethip_nic_cb_conn, nic);
    174174        if (rc != EOK) {
     
    192192                goto error;
    193193        }
    194        
     194
    195195        addr48(nic_address.address, nic->mac_addr);
    196196
     
    216216        if (in_list)
    217217                list_remove(&nic->link);
    218        
     218
    219219        if (nic->sess != NULL)
    220220                async_hangup(nic->sess);
    221        
     221
    222222        ethip_nic_delete(nic);
    223223        return rc;
     
    332332                return rc;
    333333        }
    334        
     334
    335335        return ethip_nic_check_new();
    336336}
     
    371371{
    372372        log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_setup_multicast()");
    373        
     373
    374374        /* Count the number of multicast addresses */
    375        
     375
    376376        size_t count = 0;
    377        
     377
    378378        list_foreach(nic->addr_list, link, ethip_link_addr_t, laddr) {
    379379                ip_ver_t ver = inet_addr_get(&laddr->addr, NULL, NULL);
     
    381381                        count++;
    382382        }
    383        
     383
    384384        if (count == 0)
    385385                return nic_multicast_set_mode(nic->sess, NIC_MULTICAST_BLOCKED,
    386386                    NULL, 0);
    387        
     387
    388388        nic_address_t *mac_list = calloc(count, sizeof(nic_address_t));
    389389        if (mac_list == NULL)
    390390                return ENOMEM;
    391        
     391
    392392        /* Create the multicast MAC list */
    393        
     393
    394394        size_t i = 0;
    395        
     395
    396396        list_foreach(nic->addr_list, link, ethip_link_addr_t, laddr) {
    397397                addr128_t v6;
     
    399399                if (ver != ip_v6)
    400400                        continue;
    401                
     401
    402402                assert(i < count);
    403                
     403
    404404                addr48_t mac;
    405405                addr48_solicited_node(v6, mac);
    406                
     406
    407407                /* Avoid duplicate addresses in the list */
    408                
     408
    409409                bool found = false;
    410                
     410
    411411                for (size_t j = 0; j < i; j++) {
    412412                        if (addr48_compare(mac_list[j].address, mac)) {
     
    415415                        }
    416416                }
    417                
     417
    418418                if (!found) {
    419419                        addr48(mac, mac_list[i].address);
     
    422422                        count--;
    423423        }
    424        
     424
    425425        /* Setup the multicast MAC list */
    426        
     426
    427427        errno_t rc = nic_multicast_set_mode(nic->sess, NIC_MULTICAST_LIST,
    428428            mac_list, count);
    429        
     429
    430430        free(mac_list);
    431431        return rc;
     
    435435{
    436436        log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_add()");
    437        
     437
    438438        ethip_link_addr_t *laddr = ethip_nic_addr_new(addr);
    439439        if (laddr == NULL)
    440440                return ENOMEM;
    441        
     441
    442442        list_append(&laddr->link, &nic->addr_list);
    443        
     443
    444444        return ethip_nic_setup_multicast(nic);
    445445}
     
    448448{
    449449        log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_remove()");
    450        
     450
    451451        ethip_link_addr_t *laddr = ethip_nic_addr_find(nic, addr);
    452452        if (laddr == NULL)
    453453                return ENOENT;
    454        
     454
    455455        list_remove(&laddr->link);
    456456        ethip_link_addr_delete(laddr);
    457        
     457
    458458        return ethip_nic_setup_multicast(nic);
    459459}
     
    463463{
    464464        log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_find()");
    465        
     465
    466466        list_foreach(nic->addr_list, link, ethip_link_addr_t, laddr) {
    467467                if (inet_addr_compare(addr, &laddr->addr))
    468468                        return laddr;
    469469        }
    470        
     470
    471471        return NULL;
    472472}
Note: See TracChangeset for help on using the changeset viewer.