Changeset f959a20f in mainline for uspace/srv/devman/match.c


Ignore:
Timestamp:
2019-02-01T22:32:38Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
00b7fc8
Parents:
1a37496
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-01 21:22:39)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-01 22:32:38)
Message:

Avoid directly using .head/.next/.prev of list_t/link_t

Use existing constructs from <adt/list.h> instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/match.c

    r1a37496 rf959a20f  
    6767int get_match_score(driver_t *drv, dev_node_t *dev)
    6868{
    69         link_t *drv_head = &drv->match_ids.ids.head;
    70         link_t *dev_head = &dev->pfun->match_ids.ids.head;
    71 
    72         if (list_empty(&drv->match_ids.ids) ||
    73             list_empty(&dev->pfun->match_ids.ids)) {
     69        list_t *drv_list = &drv->match_ids.ids;
     70        list_t *dev_list = &dev->pfun->match_ids.ids;
     71
     72        if (list_empty(drv_list) || list_empty(dev_list))
    7473                return 0;
    75         }
    7674
    7775        /*
     
    8078        int highest_score = 0;
    8179
    82         link_t *drv_link = drv->match_ids.ids.head.next;
    83         while (drv_link != drv_head) {
    84                 link_t *dev_link = dev_head->next;
    85                 while (dev_link != dev_head) {
    86                         match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link);
    87                         match_id_t *dev_id = list_get_instance(dev_link, match_id_t, link);
    88 
     80        list_foreach(*drv_list, link, match_id_t, drv_id) {
     81                list_foreach(*dev_list, link, match_id_t, dev_id) {
    8982                        int score = compute_match_score(drv_id, dev_id);
    90                         if (score > highest_score) {
     83                        if (score > highest_score)
    9184                                highest_score = score;
    92                         }
    93 
    94                         dev_link = dev_link->next;
    9585                }
    96 
    97                 drv_link = drv_link->next;
    9886        }
    9987
Note: See TracChangeset for help on using the changeset viewer.