[riot-notifications] [RIOT-OS/RIOT] usbus: simplify adding entry to list (#11726)

Kees Bakker notifications at github.com
Wed Jun 19 22:40:54 CEST 2019

### Contribution description

This is a code simplification albeit that it will now use a pointer-pointer
(which some may claim to add complexity).
The advantage is that no initial if is needed. And it's my believe that
a compiler will make fairly optimized code for it, even with the pointer-pointer.

The original code is this
    usbus_handler_t *last = usbus->handlers;

    if (last) {
        while (last->next) {
            last = last->next;
        last->next = handler;
    else {
        usbus->handlers = handler;

and the new code is this

    usbus_handler_t **last = &usbus->handlers;
    while (*last) {
        last = &(*last)->next;
    *last = handler;

### Testing procedure

That particalur USB code is fairly new and only used in `cdc_ecm.c`. Are there
actual USB tests (besides running some examples)?

### Issues/PRs references

The code was recently added in #10916.
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * usbus: simplify adding entry to list

-- File Changes --

    M sys/usb/usbus/usbus.c (29)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190619/ce30a3ab/attachment-0001.html>

More information about the notifications mailing list