The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.
To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.
--- Begin Message ---
Op 06-04-2023 om 23:39 schreef Sergey Ponomarev:
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;
Hi Sergey,
Seems okay, but one remark. An else branch after statements like
continue or return is not needed. Without the else the code saves
indents and becomes clearer.
So:
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;
+ }
+ if (c == 0) {
+ uh->req_type = i;
+ return 0;
+ }
+ return -1;
}
return -1;
Also it looks like the return -1 after the loop can/should be dropped as
that (iff request_types is sorted and contains > 0 elements) can never
be reached. Or the return at the end of the loop block could be dropped
as it provides a neglectible optimalisation.
Regards, Paul
--- End Message ---
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel