mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
net/nanocoap: return error from coap_opt_finish if no space
This commit is contained in:
parent
3cdf43607c
commit
5bf2fc6227
@ -669,6 +669,7 @@ static inline ssize_t coap_opt_add_format(coap_pkt_t *pkt, uint16_t format)
|
||||
* @param[in] flags see COAP_OPT_FINISH... macros
|
||||
*
|
||||
* @return total number of bytes written to buffer
|
||||
* @return -ENOSPC if no buffer space for payload marker
|
||||
*/
|
||||
ssize_t coap_opt_finish(coap_pkt_t *pkt, uint16_t flags);
|
||||
|
||||
|
@ -797,7 +797,9 @@ ssize_t coap_opt_add_uint(coap_pkt_t *pkt, uint16_t optnum, uint32_t value)
|
||||
ssize_t coap_opt_finish(coap_pkt_t *pkt, uint16_t flags)
|
||||
{
|
||||
if (flags & COAP_OPT_FINISH_PAYLOAD) {
|
||||
assert(pkt->payload_len > 1);
|
||||
if (!pkt->payload_len) {
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
*pkt->payload++ = 0xFF;
|
||||
pkt->payload_len--;
|
||||
|
Loading…
Reference in New Issue
Block a user