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/lib/usbhid/src/hiddescriptor.c

    r1a37496 rf959a20f  
    8989    usb_hid_report_path_t *cmp_path)
    9090{
    91         link_t *path_it = report->collection_paths.head.next;
    92         usb_hid_report_path_t *path = NULL;
    93 
    94         if ((report == NULL) || (cmp_path == NULL)) {
     91        if (report == NULL || cmp_path == NULL)
    9592                return NULL;
    96         }
    97 
    98         while (path_it != &report->collection_paths.head) {
    99                 path = list_get_instance(path_it, usb_hid_report_path_t,
    100                     cpath_link);
    101 
     93
     94        list_foreach(report->collection_paths, cpath_link, usb_hid_report_path_t, path) {
    10295                if (usb_hid_report_compare_usage_path(path, cmp_path,
    103                     USB_HID_PATH_COMPARE_STRICT) == 0) {
    104                         break;
    105                 }
    106                 path_it = path_it->next;
    107         }
    108         if (path_it == &report->collection_paths.head) {
    109                 path = usb_hid_report_path_clone(cmp_path);
    110                 if (path == NULL) {
    111                         return NULL;
    112                 }
    113                 list_append(&path->cpath_link, &report->collection_paths);
    114                 report->collection_paths_count++;
    115 
    116                 return path;
    117         } else {
    118                 return list_get_instance(path_it, usb_hid_report_path_t,
    119                     cpath_link);
    120         }
     96                    USB_HID_PATH_COMPARE_STRICT) == 0)
     97                        return path;
     98        }
     99
     100        usb_hid_report_path_t *path = usb_hid_report_path_clone(cmp_path);
     101        if (path == NULL)
     102                return NULL;
     103
     104        list_append(&path->cpath_link, &report->collection_paths);
     105        report->collection_paths_count++;
     106
     107        return path;
    121108}
    122109
     
    474461                                    usb_hid_report_item_t, link);
    475462
     463                                link_t *tmp_link = list_prev(
     464                                    &report_item->usage_path->cpath_link,
     465                                    &report->collection_paths);
     466                                assert(tmp_link);
     467
    476468                                usb_hid_report_usage_path_t *tmp_usage_path;
    477                                 tmp_usage_path = list_get_instance(
    478                                     report_item->usage_path->cpath_link.prev,
     469                                tmp_usage_path = list_get_instance(tmp_link,
    479470                                    usb_hid_report_usage_path_t, rpath_items_link);
    480471
     
    486477
    487478                                usb_hid_report_path_free(report_item->usage_path);
    488                                 list_remove (item_link);
     479                                list_remove(item_link);
    489480
    490481                                break;
Note: See TracChangeset for help on using the changeset viewer.