Signed-off-by: Sergey Ponomarev <stok...@gmail.com> --- uclient-http.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/uclient-http.c b/uclient-http.c index c2bba6b..80d4495 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -40,11 +40,11 @@ enum auth_type { }; enum request_type { + REQ_DELETE, REQ_GET, REQ_HEAD, REQ_POST, REQ_PUT, - REQ_DELETE, __REQ_MAX }; @@ -57,12 +57,13 @@ enum http_state { HTTP_STATE_ERROR, }; +// Must be sorted aplhabeticaly static const char * const request_types[__REQ_MAX] = { + [REQ_DELETE] = "DELETE", [REQ_GET] = "GET", [REQ_HEAD] = "HEAD", [REQ_POST] = "POST", [REQ_PUT] = "PUT", - [REQ_DELETE] = "DELETE", }; struct uclient_http { @@ -991,11 +992,15 @@ uclient_http_set_request_type(struct uclient *cl, const char *type) return -1; for (i = 0; i < ARRAY_SIZE(request_types); i++) { - if (strcmp(request_types[i], type) != 0) + int c = strcmp(request_types[i], type); + if (c < 0) { continue; - - uh->req_type = i; - return 0; + } else if (c == 0) { + uh->req_type = i; + return 0; + } else { + return -1; + } } return -1; -- 2.37.2 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel