From 6a2e89a015c91510bb1038032654d0e9f921de23 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 5 Aug 2015 09:24:23 +0200 Subject: [PATCH 1/4] libcoap: updated patches enumeration --- pkg/libcoap/0001-Add-RIOT-Makefile.patch | 2 +- pkg/libcoap/0002-Add-config.h.patch | 2 +- pkg/libcoap/0003-Remove-two-example-programs-in-root.patch | 2 +- .../0004-Eliminate-some-compiler-warnings-and-errors.patch | 2 +- pkg/libcoap/0005-fix-old-style-function-declarations.patch | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/libcoap/0001-Add-RIOT-Makefile.patch b/pkg/libcoap/0001-Add-RIOT-Makefile.patch index 8bb2c8ab2c..f15c3ec0c3 100644 --- a/pkg/libcoap/0001-Add-RIOT-Makefile.patch +++ b/pkg/libcoap/0001-Add-RIOT-Makefile.patch @@ -1,7 +1,7 @@ From b3ef68af33cb65f36666a416b71d7eb768715eca Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 31 Oct 2013 13:36:10 +0100 -Subject: [PATCH 1/4] Add RIOT Makefile +Subject: [PATCH 1/8] Add RIOT Makefile --- Makefile | 5 +++++ diff --git a/pkg/libcoap/0002-Add-config.h.patch b/pkg/libcoap/0002-Add-config.h.patch index 6f55e50576..cda432279a 100644 --- a/pkg/libcoap/0002-Add-config.h.patch +++ b/pkg/libcoap/0002-Add-config.h.patch @@ -1,7 +1,7 @@ From 8be22676f13bd7d254378e2c04119e1632ed55d7 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 31 Oct 2013 14:02:07 +0100 -Subject: [PATCH 2/4] Add config.h +Subject: [PATCH 2/8] Add config.h --- config.h | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/pkg/libcoap/0003-Remove-two-example-programs-in-root.patch b/pkg/libcoap/0003-Remove-two-example-programs-in-root.patch index 9e529d7708..e5cd9bef4e 100644 --- a/pkg/libcoap/0003-Remove-two-example-programs-in-root.patch +++ b/pkg/libcoap/0003-Remove-two-example-programs-in-root.patch @@ -1,7 +1,7 @@ From e53472f0a5f15d2459bf9a9ef40d2b302bb80f8b Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Tue, 15 Jul 2014 16:57:07 +0200 -Subject: [PATCH 3/4] Remove two example programs in root +Subject: [PATCH 3/8] Remove two example programs in root --- coap-observer.c | 185 ----------------------------------------------- diff --git a/pkg/libcoap/0004-Eliminate-some-compiler-warnings-and-errors.patch b/pkg/libcoap/0004-Eliminate-some-compiler-warnings-and-errors.patch index ccbd633980..6e7a5e6b4a 100644 --- a/pkg/libcoap/0004-Eliminate-some-compiler-warnings-and-errors.patch +++ b/pkg/libcoap/0004-Eliminate-some-compiler-warnings-and-errors.patch @@ -1,7 +1,7 @@ From 48906fde395dc05c18606ddf3abce5947ab6a1c6 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 19 Feb 2014 02:24:50 +0100 -Subject: [PATCH 4/4] Eliminate some compiler warnings and errors +Subject: [PATCH 4/5] Eliminate some compiler warnings and errors --- address.h | 4 ++++ diff --git a/pkg/libcoap/0005-fix-old-style-function-declarations.patch b/pkg/libcoap/0005-fix-old-style-function-declarations.patch index f601ada78d..db49ed0b6e 100644 --- a/pkg/libcoap/0005-fix-old-style-function-declarations.patch +++ b/pkg/libcoap/0005-fix-old-style-function-declarations.patch @@ -1,7 +1,7 @@ From e6d36f466b2c1568cb4cfc3a3f1f9348e71db037 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Tue, 15 Jul 2014 17:06:51 +0200 -Subject: [PATCH] fix old-style function declarations +Subject: [PATCH 5/8] fix old-style function declarations --- async.c | 2 +- From ee44d7367de71de566d0dee890e73541436c502c Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Tue, 4 Aug 2015 23:19:08 +0200 Subject: [PATCH 2/4] libcoap: do not misuse NDEBUG macro --- .../0006-debug-do-not-misuse-NDEBUG.patch | 263 ++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 pkg/libcoap/0006-debug-do-not-misuse-NDEBUG.patch diff --git a/pkg/libcoap/0006-debug-do-not-misuse-NDEBUG.patch b/pkg/libcoap/0006-debug-do-not-misuse-NDEBUG.patch new file mode 100644 index 0000000000..d365c06dd4 --- /dev/null +++ b/pkg/libcoap/0006-debug-do-not-misuse-NDEBUG.patch @@ -0,0 +1,263 @@ +From ca876797dbe6ba05f75a451e8724495a0770fe86 Mon Sep 17 00:00:00 2001 +From: Oleg Hahm +Date: Thu, 23 Jul 2015 10:20:38 +0200 +Subject: [PATCH 6/8] debug: do not misuse NDEBUG + +--- + coap_list.c | 2 +- + debug.c | 4 ++-- + debug.h | 3 +++ + encode.c | 2 +- + examples/client.c | 4 ++-- + net.c | 12 ++++++------ + pdu.c | 2 +- + resource.c | 2 +- + str.c | 2 +- + subscribe.c | 14 +++++++------- + 10 files changed, 25 insertions(+), 22 deletions(-) + +diff --git a/coap_list.c b/coap_list.c +index e93003c..95da094 100644 +--- a/coap_list.c ++++ b/coap_list.c +@@ -74,7 +74,7 @@ coap_list_t * + coap_new_listnode(void *data, void (*delete_func)(void *) ) { + coap_list_t *node = coap_malloc( sizeof(coap_list_t) ); + if ( ! node ) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + coap_log(LOG_CRIT, "coap_new_listnode: malloc\n"); + #endif + return NULL; +diff --git a/debug.c b/debug.c +index adff3c2..e043225 100644 +--- a/debug.c ++++ b/debug.c +@@ -86,7 +86,7 @@ print_timestamp(char *s, size_t len, coap_tick_t t) { + + #endif /* HAVE_TIME_H */ + +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + + #ifndef HAVE_STRNLEN + /** +@@ -326,7 +326,7 @@ coap_show_pdu(const coap_pdu_t *pdu) { + } + #endif /* WITH_CONTIKI */ + +-#endif /* NDEBUG */ ++#endif /* DEBUG_ENABLED */ + + #ifndef WITH_CONTIKI + void +diff --git a/debug.h b/debug.h +index d18558f..edf4b86 100644 +--- a/debug.h ++++ b/debug.h +@@ -54,7 +54,10 @@ void coap_log_impl(coap_log_t level, const char *format, ...); + #endif + + #ifndef NDEBUG ++#define DEBUG_ENABLED ++#endif + ++#ifdef DEBUG_ENABLED + /* A set of convenience macros for common log levels. */ + #define info(...) coap_log(LOG_INFO, __VA_ARGS__) + #define warn(...) coap_log(LOG_WARNING, __VA_ARGS__) +diff --git a/encode.c b/encode.c +index b034b6b..cdd9a20 100644 +--- a/encode.c ++++ b/encode.c +@@ -6,7 +6,7 @@ + * README for terms of use. + */ + +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + # include + #endif + +diff --git a/examples/client.c b/examples/client.c +index bd75deb..7872c35 100644 +--- a/examples/client.c ++++ b/examples/client.c +@@ -282,7 +282,7 @@ message_handler(struct coap_context_t *ctx, + unsigned char *databuf; + coap_tid_t tid; + +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + if (LOG_DEBUG <= coap_get_log_level()) { + debug("** process incoming %d.%02d response:\n", + (received->hdr->code >> 5), received->hdr->code & 0x1F); +@@ -1075,7 +1075,7 @@ main(int argc, char **argv) { + if (! (pdu = coap_new_request(ctx, method, optlist))) + return -1; + +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + if (LOG_DEBUG <= coap_get_log_level()) { + debug("sending CoAP request:\n"); + coap_show_pdu(pdu); +diff --git a/net.c b/net.c +index 7338802..9372570 100644 +--- a/net.c ++++ b/net.c +@@ -243,7 +243,7 @@ coap_new_node() { + node = coap_malloc_node(); + + if ( ! node ) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + coap_log(LOG_WARNING, "coap_new_node: malloc\n"); + #endif + return NULL; +@@ -327,7 +327,7 @@ coap_new_context( + + #ifndef WITH_CONTIKI + if ( !c ) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + coap_log(LOG_EMERG, "coap_init: malloc:\n"); + #endif + return NULL; +@@ -362,20 +362,20 @@ coap_new_context( + #ifdef WITH_POSIX + c->sockfd = socket(listen_addr->addr.sa.sa_family, SOCK_DGRAM, 0); + if ( c->sockfd < 0 ) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + coap_log(LOG_EMERG, "coap_new_context: socket\n"); + #endif /* WITH_POSIX */ + goto onerror; + } + + if ( setsockopt( c->sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse) ) < 0 ) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + coap_log(LOG_WARNING, "setsockopt SO_REUSEADDR\n"); + #endif + } + + if (bind(c->sockfd, &listen_addr->addr.sa, listen_addr->size) < 0) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + coap_log(LOG_EMERG, "coap_new_context: bind\n"); + #endif + goto onerror; +@@ -923,7 +923,7 @@ if (!coap_pdu_parse((unsigned char *)buf, bytes_read, node->pdu)) { + coap_transaction_id(&node->remote, node->pdu, &node->id); + coap_insert_node(&ctx->recvqueue, node); + +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + if (LOG_DEBUG <= coap_get_log_level()) { + #ifndef INET6_ADDRSTRLEN + #define INET6_ADDRSTRLEN 40 +diff --git a/pdu.c b/pdu.c +index 04ef9c6..05d8537 100644 +--- a/pdu.c ++++ b/pdu.c +@@ -132,7 +132,7 @@ coap_new_pdu() { + pdu = coap_pdu_init(0, 0, uip_ntohs(COAP_INVALID_TID), COAP_MAX_PDU_SIZE); + #endif /* WITH_CONTIKI */ + +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + if (!pdu) + coap_log(LOG_CRIT, "coap_new_pdu: cannot allocate memory for new PDU\n"); + #endif +diff --git a/resource.c b/resource.c +index 1d9cf34..101ea4d 100644 +--- a/resource.c ++++ b/resource.c +@@ -821,4 +821,4 @@ coap_remove_failed_observers(coap_context_t *context, +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + if (LOG_DEBUG <= coap_get_log_level()) { + #ifndef INET6_ADDRSTRLEN + #define INET6_ADDRSTRLEN 40 +diff --git a/str.c b/str.c +index 0956789..f997ced 100644 +--- a/str.c ++++ b/str.c +@@ -17,7 +17,7 @@ + str *coap_new_string(size_t size) { + str *s = coap_malloc(sizeof(str) + size + 1); + if ( !s ) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + coap_log(LOG_CRIT, "coap_new_string: malloc\n"); + #endif + return NULL; +diff --git a/subscribe.c b/subscribe.c +index d683419..37d4e20 100644 +--- a/subscribe.c ++++ b/subscribe.c +@@ -43,7 +43,7 @@ notify(coap_context_t *context, coap_resource_t *res, + int ls, finished=0; + unsigned char ct, d; + unsigned int length; +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + char addr[INET6_ADDRSTRLEN]; + #endif + +@@ -90,7 +90,7 @@ notify(coap_context_t *context, coap_resource_t *res, + /* TODO: add mediatype */ + } + +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + if ( inet_ntop(sub->subscriber.addr.sa.sa_family, + &sub->subscriber.addr, addr, sizeof(addr)) ) { + debug("*** notify for %s to [%s]\n", res->uri->path.s, addr); +@@ -100,7 +100,7 @@ notify(coap_context_t *context, coap_resource_t *res, + &sub->subscriber.addr.sa, + sub->subscriber.size, pdu) + == COAP_INVALID_TID) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + debug("coap_check_resource_list: error sending notification\n"); + #endif + coap_delete_pdu(pdu); +@@ -164,7 +164,7 @@ coap_get_resource_from_key(coap_context_t *ctx, coap_key_t key) { + + coap_resource_t * + coap_get_resource(coap_context_t *ctx, coap_uri_t *uri) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + int i; + printf("search resource %ux", coap_uri_hash(uri)); + for (i=0; i < uri->path.length; ++i) { +@@ -180,7 +180,7 @@ void + coap_check_subscriptions(coap_context_t *context) { + time_t now; + coap_list_t *node; +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + char addr[INET6_ADDRSTRLEN]; + #endif + +@@ -191,7 +191,7 @@ coap_check_subscriptions(coap_context_t *context) { + + node = context->subscriptions; + while ( node && COAP_SUBSCRIPTION(node)->expires < now ) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + if (inet_ntop(COAP_SUBSCRIPTION(node)->subscriber.addr.sa.sa_family, + &COAP_SUBSCRIPTION(node)->subscriber.addr, + addr, sizeof(addr))) { +@@ -236,7 +236,7 @@ coap_delete_resource(coap_context_t *context, coap_key_t key) { + for (prev = NULL, node = context->resources; node; + prev = node, node = node->next) { + if (coap_uri_hash(COAP_RESOURCE(node)->uri) == key) { +-#ifndef NDEBUG ++#ifdef DEBUG_ENABLED + debug("removed key %lu (%s)\n",key,COAP_RESOURCE(node)->uri->path.s); + #endif + if (!prev) +-- +2.5.0 From 1fe0c158f6a1706ec834b8c518f4780548a86946 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Tue, 4 Aug 2015 23:19:34 +0200 Subject: [PATCH 3/4] libcoap: fix bracketing for option parsing w/ debug --- ...ix-option-parsing-with-debug-enabled.patch | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pkg/libcoap/0007-fix-option-parsing-with-debug-enabled.patch diff --git a/pkg/libcoap/0007-fix-option-parsing-with-debug-enabled.patch b/pkg/libcoap/0007-fix-option-parsing-with-debug-enabled.patch new file mode 100644 index 0000000000..d5fb8fef44 --- /dev/null +++ b/pkg/libcoap/0007-fix-option-parsing-with-debug-enabled.patch @@ -0,0 +1,26 @@ +From e5adb25f18ff979b2777f7161b1038611c84a450 Mon Sep 17 00:00:00 2001 +From: Oleg Hahm +Date: Tue, 4 Aug 2015 23:07:24 +0200 +Subject: [PATCH 7/8] fix option parsing with debug enabled + +--- + option.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/option.c b/option.c +index a03fc9e..b825eac 100644 +--- a/option.c ++++ b/option.c +@@ -57,8 +57,9 @@ coap_opt_parse(const coap_opt_t *opt, size_t length, coap_option_t *result) { + + switch(result->delta) { + case 15: +- if (*opt != COAP_PAYLOAD_START) ++ if (*opt != COAP_PAYLOAD_START) { + debug("ignored reserved option delta 15\n"); ++ } + return 0; + case 14: + /* Handle two-byte value: First, the MSB + 269 is stored as delta value. +-- +2.5.0 From 733d630e0407f6d7e45533da5874bf10881f77d1 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Tue, 4 Aug 2015 23:19:51 +0200 Subject: [PATCH 4/4] libcoap: fix bracketing in PDU parsing w/ debug --- .../0008-fix-debug-out-in-PDU-parsing.patch | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 pkg/libcoap/0008-fix-debug-out-in-PDU-parsing.patch diff --git a/pkg/libcoap/0008-fix-debug-out-in-PDU-parsing.patch b/pkg/libcoap/0008-fix-debug-out-in-PDU-parsing.patch new file mode 100644 index 0000000000..c41d009c96 --- /dev/null +++ b/pkg/libcoap/0008-fix-debug-out-in-PDU-parsing.patch @@ -0,0 +1,27 @@ +From 3409c3834022c9e7cd73ac69e34dfaa101947cf0 Mon Sep 17 00:00:00 2001 +From: Oleg Hahm +Date: Tue, 4 Aug 2015 23:09:27 +0200 +Subject: [PATCH 8/8] fix debug out in PDU parsing + +--- + net.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/net.c b/net.c +index 9372570..86c7793 100644 +--- a/net.c ++++ b/net.c +@@ -930,9 +930,10 @@ if (!coap_pdu_parse((unsigned char *)buf, bytes_read, node->pdu)) { + #endif + unsigned char addr[INET6_ADDRSTRLEN+8]; + +- if (coap_print_addr(&src, addr, INET6_ADDRSTRLEN+8)) ++ if (coap_print_addr(&src, addr, INET6_ADDRSTRLEN+8)) { + debug("** received %d bytes from %s:\n", (int)bytes_read, addr); + ++ } + coap_show_pdu( node->pdu ); + } + #endif +-- +2.5.0