net/nanocoap: Packet API return error if buffer full#10931
Merged
kaspar030 merged 5 commits intoRIOT-OS:masterfrom Apr 3, 2019
Merged
net/nanocoap: Packet API return error if buffer full#10931kaspar030 merged 5 commits intoRIOT-OS:masterfrom
kaspar030 merged 5 commits intoRIOT-OS:masterfrom
Conversation
This was referenced Feb 11, 2019
Contributor
|
@kb2ma pls rebase! |
c1f7433 to
0fa6eb1
Compare
Member
Author
|
Rebased, apologies for the delay. |
smlng
suggested changes
Mar 17, 2019
Member
Author
|
Added a couple of fixup commits to address these issues. |
smlng
approved these changes
Mar 19, 2019
Member
|
please squash |
cba9892 to
7d259cc
Compare
Member
Author
|
Squashed and successful build. |
Contributor
|
ACK from my side, too. &go. |
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.
Contribution description
nanocoap's Packet API is meant to be safer to use than the Buffer API. Historically, an attempt to overfill the buffer with this API would generate an assert. However, given the pressure to optimize buffer sizes, it can be useful to provide the ability to recover from a write that would overfill the buffer.
This PR builds on #10823 to return -ENOSPC if a request to write to the message buffer is too long. This response applies to coap_opt_add_xxx() and coap_opt_finish() functions. An error return value allows an application response to recover, for example by returning a 5.00 error.
This PR also updates the module documentation to be clearer about application responsibility for managing the message buffer with each API.
Testing procedure
Includes unit tests for nanocoap and gcoap.
Issues/PRs references
Completes the work started in #10823 and #10926.