diff --git a/sys/include/net/gcoap.h b/sys/include/net/gcoap.h index 92006c045a52..b9d4794d1b60 100644 --- a/sys/include/net/gcoap.h +++ b/sys/include/net/gcoap.h @@ -750,8 +750,7 @@ typedef struct { * @brief A modular collection of resources for a server */ struct gcoap_listener { - const coap_resource_t *resources; /**< First element in the array of - * resources; must order alphabetically */ + const coap_resource_t *resources; /**< First element in the array of resources */ size_t resources_len; /**< Length of array */ /** * @brief Transport type for the listener diff --git a/sys/net/application_layer/gcoap/gcoap.c b/sys/net/application_layer/gcoap/gcoap.c index 381735199b95..8d79ee2c014b 100644 --- a/sys/net/application_layer/gcoap/gcoap.c +++ b/sys/net/application_layer/gcoap/gcoap.c @@ -744,13 +744,9 @@ static int _request_matcher_default(gcoap_listener_t *listener, int res = coap_match_path(*resource, uri); /* URI mismatch */ - if (res > 0) { + if (res != 0) { continue; } - /* resources expected in alphabetical order */ - else if (res < 0) { - break; - } /* potential match, check for method */ if (! ((*resource)->methods & method_flag)) { diff --git a/sys/net/application_layer/nanocoap/nanocoap.c b/sys/net/application_layer/nanocoap/nanocoap.c index 78d14bb6b1ba..2fb397e34a0c 100644 --- a/sys/net/application_layer/nanocoap/nanocoap.c +++ b/sys/net/application_layer/nanocoap/nanocoap.c @@ -454,18 +454,14 @@ ssize_t coap_tree_handler(coap_pkt_t *pkt, uint8_t *resp_buf, } int res = coap_match_path(resource, uri); - if (res > 0) { + if (res != 0) { continue; } - else if (res < 0) { - break; - } - else { - coap_request_ctx_t ctx = { - .resource = resource, - }; - return resource->handler(pkt, resp_buf, resp_buf_len, &ctx); - } + + coap_request_ctx_t ctx = { + .resource = resource, + }; + return resource->handler(pkt, resp_buf, resp_buf_len, &ctx); } return coap_build_reply(pkt, COAP_CODE_404, resp_buf, resp_buf_len, 0);