gcoap: add asserts for path in gcoap_req_init

This commit is contained in:
smlng 2018-05-04 11:08:48 +02:00
parent c9e9f72454
commit b9ca8f466f
2 changed files with 6 additions and 0 deletions

View File

@ -506,6 +506,9 @@ void gcoap_register_listener(gcoap_listener_t *listener);
* @param[in] code Request code: GCOAP_[GET|POST|PUT|DELETE]
* @param[in] path Resource path, *must* start with '/'
*
* @pre @p path not `NULL`
* @pre @p path must start with `/`
*
* @return 0 on success
* @return < 0 on error
*/

View File

@ -22,6 +22,7 @@
#include <stdint.h>
#include <stdatomic.h>
#include "assert.h"
#include "net/gcoap.h"
#include "mutex.h"
#include "random.h"
@ -718,6 +719,8 @@ void gcoap_register_listener(gcoap_listener_t *listener)
int gcoap_req_init(coap_pkt_t *pdu, uint8_t *buf, size_t len,
unsigned code, const char *path)
{
assert((path != NULL) && (path[0] == '/'));
(void)len;
pdu->hdr = (coap_hdr_t *)buf;