1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #18848 from benpicco/coap_build_reply-return

examples: check return value of coap_build_reply()
This commit is contained in:
Marian Buschsieweke 2022-11-07 12:20:42 +01:00 committed by GitHub
commit 13eef005ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -150,6 +150,10 @@ ssize_t _sha256_handler(coap_pkt_t* pkt, uint8_t *buf, size_t len, coap_request_
}
ssize_t reply_len = coap_build_reply(pkt, result, buf, len, 0);
if (reply_len <= 0) {
return reply_len;
}
uint8_t *pkt_pos = (uint8_t*)pkt->hdr + reply_len;
if (blockwise) {
pkt_pos += coap_opt_put_block1_control(pkt_pos, 0, &block1);

View File

@ -66,6 +66,10 @@ ssize_t _flashwrite_handler(coap_pkt_t* pkt, uint8_t *buf, size_t len, coap_requ
}
ssize_t reply_len = coap_build_reply(pkt, result, buf, len, 0);
if (reply_len <= 0) {
return reply_len;
}
uint8_t *pkt_pos = (uint8_t*)pkt->hdr + reply_len;
pkt_pos += coap_put_block1_ok(pkt_pos, &block1, 0);