Skip to content

net/nanocoap: Packet API return error if buffer full#10931

Merged
kaspar030 merged 5 commits intoRIOT-OS:masterfrom
kb2ma:nanocoap/pktapi_opt_enospc
Apr 3, 2019
Merged

net/nanocoap: Packet API return error if buffer full#10931
kaspar030 merged 5 commits intoRIOT-OS:masterfrom
kb2ma:nanocoap/pktapi_opt_enospc

Conversation

@kb2ma
Copy link
Copy Markdown
Member

@kb2ma kb2ma commented Feb 3, 2019

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.

@kb2ma kb2ma requested a review from smlng February 3, 2019 12:33
@kb2ma kb2ma added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: CoAP Area: Constrained Application Protocol implementations labels Feb 3, 2019
@kb2ma kb2ma added this to the Release 2019.04 milestone Feb 24, 2019
@kaspar030 kaspar030 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 12, 2019
@kaspar030
Copy link
Copy Markdown
Contributor

@kb2ma pls rebase!

@kb2ma kb2ma force-pushed the nanocoap/pktapi_opt_enospc branch from c1f7433 to 0fa6eb1 Compare March 17, 2019 12:01
@kb2ma
Copy link
Copy Markdown
Member Author

kb2ma commented Mar 17, 2019

Rebased, apologies for the delay.

@kb2ma
Copy link
Copy Markdown
Member Author

kb2ma commented Mar 19, 2019

Added a couple of fixup commits to address these issues.

@smlng
Copy link
Copy Markdown
Member

smlng commented Mar 19, 2019

please squash

@kb2ma kb2ma force-pushed the nanocoap/pktapi_opt_enospc branch from cba9892 to 7d259cc Compare March 19, 2019 09:32
@kb2ma
Copy link
Copy Markdown
Member Author

kb2ma commented Mar 19, 2019

Squashed and successful build.

@kaspar030
Copy link
Copy Markdown
Contributor

ACK from my side, too. &go.

@kaspar030 kaspar030 merged commit 8817169 into RIOT-OS:master Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: CoAP Area: Constrained Application Protocol implementations CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants