Changeset 46577995 in mainline for uspace/lib/nic/src/nic_impl.c


Ignore:
Timestamp:
2018-01-04T20:50:52Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
e211ea04
Parents:
facacc71
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:47:53)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:50:52)
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.

After this commit, HelenOS is free of code that mixes error codes with non-error
values on the assumption that error codes are negative.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/nic/src/nic_impl.c

    rfacacc71 r46577995  
    5252 * @return EOK always.
    5353 */
    54 int nic_get_state_impl(ddf_fun_t *fun, nic_device_state_t *state)
     54errno_t nic_get_state_impl(ddf_fun_t *fun, nic_device_state_t *state)
    5555{
    5656        nic_t *nic_data = nic_get_from_ddf_fun(fun);
     
    7272 * @return EINVAL       If the state cannot be changed
    7373 */
    74 int nic_set_state_impl(ddf_fun_t *fun, nic_device_state_t state)
     74errno_t nic_set_state_impl(ddf_fun_t *fun, nic_device_state_t state)
    7575{
    7676        if (state >= NIC_STATE_MAX) {
     
    108108        }
    109109        if (event_handler != NULL) {
    110                 int rc = event_handler(nic_data);
     110                errno_t rc = event_handler(nic_data);
    111111                if (rc != EOK) {
    112112                        fibril_rwlock_write_unlock(&nic_data->main_lock);
     
    117117        if (state == NIC_STATE_STOPPED) {
    118118                /* Notify upper layers that we are reseting the MAC */
    119                 int rc = nic_ev_addr_changed(nic_data->client_session,
     119                errno_t rc = nic_ev_addr_changed(nic_data->client_session,
    120120                        &nic_data->default_mac);
    121121                nic_data->poll_mode = nic_data->default_poll_mode;
     
    168168 * @return EBUSY        If the device is not in state when the frame can be sent.
    169169 */
    170 int nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size)
     170errno_t nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size)
    171171{
    172172        nic_t *nic_data = nic_get_from_ddf_fun(fun);
     
    191191 * @return EOK          On success, or an error code.
    192192 */
    193 int nic_callback_create_impl(ddf_fun_t *fun)
     193errno_t nic_callback_create_impl(ddf_fun_t *fun)
    194194{
    195195        nic_t *nic = nic_get_from_ddf_fun(fun);
     
    216216 * @return ELIMIT       If the buffer is too short
    217217 */
    218 int nic_get_address_impl(ddf_fun_t *fun, nic_address_t *address)
     218errno_t nic_get_address_impl(ddf_fun_t *fun, nic_address_t *address)
    219219{
    220220        assert(address);
     
    235235 * @return EOK (cannot fail)
    236236 */
    237 int nic_get_stats_impl(ddf_fun_t *fun, nic_device_stats_t *stats)
     237errno_t nic_get_stats_impl(ddf_fun_t *fun, nic_device_stats_t *stats)
    238238{
    239239        nic_t *nic_data = nic_get_from_ddf_fun(fun);
     
    257257 * @return EOK
    258258 */
    259 int nic_unicast_get_mode_impl(ddf_fun_t *fun, nic_unicast_mode_t *mode,
     259errno_t nic_unicast_get_mode_impl(ddf_fun_t *fun, nic_unicast_mode_t *mode,
    260260        size_t max_count, nic_address_t *addr_list, size_t *addr_count)
    261261{
     
    281281 * @return ENOMEM
    282282 */
    283 int nic_unicast_set_mode_impl(ddf_fun_t *fun,
     283errno_t nic_unicast_set_mode_impl(ddf_fun_t *fun,
    284284        nic_unicast_mode_t mode, const nic_address_t *addr_list, size_t addr_count)
    285285{
     
    294294        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    295295        fibril_rwlock_write_lock(&nic_data->rxc_lock);
    296         int rc = ENOTSUP;
     296        errno_t rc = ENOTSUP;
    297297        if (nic_data->on_unicast_mode_change) {
    298298                rc = nic_data->on_unicast_mode_change(nic_data,
     
    324324 * @return EOK
    325325 */
    326 int nic_multicast_get_mode_impl(ddf_fun_t *fun, nic_multicast_mode_t *mode,
     326errno_t nic_multicast_get_mode_impl(ddf_fun_t *fun, nic_multicast_mode_t *mode,
    327327        size_t max_count, nic_address_t *addr_list, size_t *addr_count)
    328328{
     
    348348 * @return ENOMEM
    349349 */
    350 int nic_multicast_set_mode_impl(ddf_fun_t *fun, nic_multicast_mode_t mode,
     350errno_t nic_multicast_set_mode_impl(ddf_fun_t *fun,     nic_multicast_mode_t mode,
    351351        const nic_address_t *addr_list, size_t addr_count)
    352352{
     
    361361        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    362362        fibril_rwlock_write_lock(&nic_data->rxc_lock);
    363         int rc = ENOTSUP;
     363        errno_t rc = ENOTSUP;
    364364        if (nic_data->on_multicast_mode_change) {
    365365                rc = nic_data->on_multicast_mode_change(nic_data, mode, addr_list, addr_count);
     
    381381 * @return EOK
    382382 */
    383 int nic_broadcast_get_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t *mode)
     383errno_t nic_broadcast_get_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t *mode)
    384384{
    385385        nic_t *nic_data = nic_get_from_ddf_fun(fun);
     
    401401 * @return ENOMEM
    402402 */
    403 int nic_broadcast_set_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t mode)
     403errno_t nic_broadcast_set_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t mode)
    404404{
    405405        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    406406        fibril_rwlock_write_lock(&nic_data->rxc_lock);
    407         int rc = ENOTSUP;
     407        errno_t rc = ENOTSUP;
    408408        if (nic_data->on_broadcast_mode_change) {
    409409                rc = nic_data->on_broadcast_mode_change(nic_data, mode);
     
    427427 * @return EOK
    428428 */
    429 int nic_blocked_sources_get_impl(ddf_fun_t *fun,
     429errno_t nic_blocked_sources_get_impl(ddf_fun_t *fun,
    430430        size_t max_count, nic_address_t *addr_list, size_t *addr_count)
    431431{
     
    450450 * @return ENOMEM
    451451 */
    452 int nic_blocked_sources_set_impl(ddf_fun_t *fun,
     452errno_t nic_blocked_sources_set_impl(ddf_fun_t *fun,
    453453        const nic_address_t *addr_list, size_t addr_count)
    454454{
     
    458458                nic_data->on_blocked_sources_change(nic_data, addr_list, addr_count);
    459459        }
    460         int rc = nic_rxc_blocked_sources_set(&nic_data->rx_control,
     460        errno_t rc = nic_rxc_blocked_sources_set(&nic_data->rx_control,
    461461                addr_list, addr_count);
    462462        fibril_rwlock_write_unlock(&nic_data->rxc_lock);
     
    473473 * @return ENOENT       If the mask is not set
    474474 */
    475 int nic_vlan_get_mask_impl(ddf_fun_t *fun, nic_vlan_mask_t *mask)
     475errno_t nic_vlan_get_mask_impl(ddf_fun_t *fun, nic_vlan_mask_t *mask)
    476476{
    477477        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    478478        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    479         int rc = nic_rxc_vlan_get_mask(&nic_data->rx_control, mask);
     479        errno_t rc = nic_rxc_vlan_get_mask(&nic_data->rx_control, mask);
    480480        fibril_rwlock_read_unlock(&nic_data->rxc_lock);
    481481        return rc;
     
    491491 * @return ENOMEM
    492492 */
    493 int nic_vlan_set_mask_impl(ddf_fun_t *fun, const nic_vlan_mask_t *mask)
     493errno_t nic_vlan_set_mask_impl(ddf_fun_t *fun, const nic_vlan_mask_t *mask)
    494494{
    495495        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    496496        fibril_rwlock_write_lock(&nic_data->rxc_lock);
    497         int rc = nic_rxc_vlan_set_mask(&nic_data->rx_control, mask);
     497        errno_t rc = nic_rxc_vlan_set_mask(&nic_data->rx_control, mask);
    498498        if (rc == EOK && nic_data->on_vlan_mask_change) {
    499499                nic_data->on_vlan_mask_change(nic_data, mask);
     
    518518 * @return ENOMEM       If there was not enough memory to complete the operation
    519519 */
    520 int nic_wol_virtue_add_impl(ddf_fun_t *fun, nic_wv_type_t type,
     520errno_t nic_wol_virtue_add_impl(ddf_fun_t *fun, nic_wv_type_t type,
    521521        const void *data, size_t length, nic_wv_id_t *new_id)
    522522{
     
    560560        }
    561561        /* Call the user-defined add callback */
    562         int rc = nic_data->on_wol_virtue_add(nic_data, virtue);
     562        errno_t rc = nic_data->on_wol_virtue_add(nic_data, virtue);
    563563        if (rc != EOK) {
    564564                free(virtue->data);
     
    593593 * @return ENOENT       If the virtue identifier is not valid.
    594594 */
    595 int nic_wol_virtue_remove_impl(ddf_fun_t *fun, nic_wv_id_t id)
     595errno_t nic_wol_virtue_remove_impl(ddf_fun_t *fun, nic_wv_id_t id)
    596596{
    597597        nic_t *nic_data = nic_get_from_ddf_fun(fun);
     
    629629 * @return ENOMEM       If there was not enough memory to complete the operation
    630630 */
    631 int nic_wol_virtue_probe_impl(ddf_fun_t *fun, nic_wv_id_t id,
     631errno_t nic_wol_virtue_probe_impl(ddf_fun_t *fun, nic_wv_id_t id,
    632632        nic_wv_type_t *type, size_t max_length, void *data, size_t *length)
    633633{
     
    667667 * @return ENOMEM       If there was not enough memory to complete the operation
    668668 */
    669 int nic_wol_virtue_list_impl(ddf_fun_t *fun, nic_wv_type_t type,
     669errno_t nic_wol_virtue_list_impl(ddf_fun_t *fun, nic_wv_type_t type,
    670670        size_t max_count, nic_wv_id_t *id_list, size_t *id_count)
    671671{
    672672        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    673673        fibril_rwlock_read_lock(&nic_data->wv_lock);
    674         int rc = nic_wol_virtues_list(&nic_data->wol_virtues, type,
     674        errno_t rc = nic_wol_virtues_list(&nic_data->wol_virtues, type,
    675675                max_count, id_list, id_count);
    676676        fibril_rwlock_read_unlock(&nic_data->wv_lock);
     
    688688 * @return EOK          If the operation was successfully completed
    689689  */
    690 int nic_wol_virtue_get_caps_impl(ddf_fun_t *fun, nic_wv_type_t type, int *count)
     690errno_t nic_wol_virtue_get_caps_impl(ddf_fun_t *fun, nic_wv_type_t type, int *count)
    691691{
    692692        nic_t *nic_data = nic_get_from_ddf_fun(fun);
     
    710710 * @return EPARTY       Error in communication protocol
    711711 */
    712 int nic_poll_get_mode_impl(ddf_fun_t *fun,
     712errno_t nic_poll_get_mode_impl(ddf_fun_t *fun,
    713713        nic_poll_mode_t *mode, struct timeval *period)
    714714{
     
    733733 * @return EPARTY       Error in communication protocol
    734734 */
    735 int nic_poll_set_mode_impl(ddf_fun_t *fun,
     735errno_t nic_poll_set_mode_impl(ddf_fun_t *fun,
    736736        nic_poll_mode_t mode, const struct timeval *period)
    737737{
     
    754754        }
    755755        fibril_rwlock_write_lock(&nic_data->main_lock);
    756         int rc = nic_data->on_poll_mode_change(nic_data, mode, period);
     756        errno_t rc = nic_data->on_poll_mode_change(nic_data, mode, period);
    757757        assert(rc == EOK || rc == ENOTSUP || rc == EINVAL);
    758758        if (rc == ENOTSUP && (nic_data->on_poll_request != NULL) &&
     
    783783 * @return EINVAL       If the NIC is not in state where it allows on demand polling
    784784 */
    785 int nic_poll_now_impl(ddf_fun_t *fun) {
     785errno_t nic_poll_now_impl(ddf_fun_t *fun) {
    786786        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    787787        fibril_rwlock_read_lock(&nic_data->main_lock);
     
    821821 * @return EOK always.
    822822 */
    823 int nic_open_impl(ddf_fun_t *fun)
     823errno_t nic_open_impl(ddf_fun_t *fun)
    824824{
    825825        return EOK;
Note: See TracChangeset for help on using the changeset viewer.