net_lwip_webserver: utilize pbuf_copy_partial()#992
Merged
Conversation
duempel
reviewed
Aug 16, 2021
Collaborator
duempel
left a comment
There was a problem hiding this comment.
Just tested your changes and it works fine as expected. Maybe the return value could be changed: return pbuf_copy_partial(p, dst, p->tot_len, 0);
What do you think about it?
| pbuf_copy_partial(p, dst, p->tot_len, 0); | ||
|
|
||
| return len; | ||
| return p->tot_len; |
Collaborator
There was a problem hiding this comment.
Since pbuf_copy_partial returns 'the number of bytes copied, or 0 on failure' it might be more logical to return this value instead of always p->tot_len.
Collaborator
Author
There was a problem hiding this comment.
That makes sense; I have added a commit that does just that. Thank you for the review and the suggestion!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing example code duplicates functionality that it turns out can be achieved with an existing function in lwIP (pbuf_copy_partial). Using pbuf_copy_partial() saves about 24 bytes in the net_lwip_webserver executable size and results in ever so slightly less code to maintain.