Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usbus: simplify adding entry to list #11726

Merged
merged 1 commit into from
Jun 20, 2019

Conversation

keestux
Copy link
Contributor

@keestux keestux commented Jun 19, 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.

@bergzand bergzand added Area: USB Area: Universal Serial Bus Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 20, 2019
@bergzand
Copy link
Member

Changes look good, I have some time to test them this evening

@bergzand bergzand added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines labels Jun 20, 2019
Copy link
Member

@bergzand bergzand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, ACK!

@bergzand bergzand merged commit 968e53b into RIOT-OS:master Jun 20, 2019
@keestux keestux deleted the usb-some-refactoring branch June 21, 2019 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: USB Area: Universal Serial Bus CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants