From da1f161c3cc2f2877ad69a3121048efab8a4281e Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 26 Sep 2022 20:03:51 +0200 Subject: [PATCH] gcoap: accept resources in any order --- sys/include/net/gcoap.h | 3 +-- sys/net/application_layer/gcoap/gcoap.c | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) 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)) {