Changeset f959a20f in mainline for uspace/lib/usbhid/src/hidpath.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/lib/usbhid/src/hidpath.c

    r1a37496 rf959a20f  
    250250                 * Path is prefix of the report_path
    251251                 */
    252                 report_link = report_path->items.head.next;
    253                 path_link = path->items.head.next;
    254 
    255                 while ((report_link != &report_path->items.head) &&
    256                     (path_link != &path->items.head)) {
     252                report_link = list_first(&report_path->items);
     253                path_link = list_first(&path->items);
     254
     255                while (report_link != NULL && path_link != NULL) {
    257256
    258257                        report_item = list_get_instance(report_link,
     
    268267                                return 1;
    269268                        } else {
    270                                 report_link = report_link->next;
    271                                 path_link = path_link->next;
     269                                report_link = list_next(report_link, &report_path->items);
     270                                path_link = list_next(path_link, &path->items);
    272271                        }
    273272                }
    274273
    275274                if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
    276                     (path_link == &path->items.head)) ||
    277                     ((report_link == &report_path->items.head) &&
    278                     (path_link == &path->items.head))) {
     275                    (path_link == NULL)) ||
     276                    (report_link == NULL && path_link == NULL)) {
    279277                        return 0;
    280278                } else {
     
    287285                 * Path is suffix of report_path
    288286                 */
    289                 report_link = report_path->items.head.prev;
    290                 path_link = path->items.head.prev;
     287                report_link = list_last(&report_path->items);
     288                path_link = list_last(&path->items);
    291289
    292290                if (list_empty(&path->items)) {
     
    294292                }
    295293
    296                 while ((report_link != &report_path->items.head) &&
    297                     (path_link != &path->items.head)) {
     294                while (report_link != NULL && path_link != NULL) {
    298295                        report_item = list_get_instance(report_link,
    299296                            usb_hid_report_usage_path_t, rpath_items_link);
     
    308305                                return 1;
    309306                        } else {
    310                                 report_link = report_link->prev;
    311                                 path_link = path_link->prev;
     307                                report_link = list_prev(report_link, &report_path->items);
     308                                path_link = list_prev(path_link, &path->items);
    312309                        }
    313310                }
    314311
    315                 if (path_link == &path->items.head) {
     312                if (path_link == NULL) {
    316313                        return 0;
    317314                } else {
Note: See TracChangeset for help on using the changeset viewer.