Merge pull request #9083 from smlng/pr/gcoap/cleanup

gcoap: enhance gcoap_req_init
This commit is contained in:
Sebastian Meiling 2018-05-23 10:40:54 +01:00 committed by GitHub
commit 9d83b60f3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -506,11 +506,14 @@ void gcoap_register_listener(gcoap_listener_t *listener);
* @param[in] code Request code: GCOAP_[GET|POST|PUT|DELETE] * @param[in] code Request code: GCOAP_[GET|POST|PUT|DELETE]
* @param[in] path Resource path, *must* start with '/' * @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 success
* @return < 0 on error * @return < 0 on error
*/ */
int gcoap_req_init(coap_pkt_t *pdu, uint8_t *buf, size_t len, int gcoap_req_init(coap_pkt_t *pdu, uint8_t *buf, size_t len,
unsigned code, char *path); unsigned code, const char *path);
/** /**
* @brief Finishes formatting a CoAP PDU after the payload has been written * @brief Finishes formatting a CoAP PDU after the payload has been written

View File

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