1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-15 05:55:04 -05:00

altsvc: remove the num field from the altsvc struct

It was superfluous since we have the list.size alredy

Reported-by: Jay Satiro
Fixes #5553
Closes #5563
This commit is contained in:
Daniel Stenberg 2020-06-12 17:35:35 +02:00
parent 17f2dcf6b2
commit b88bdedf9c
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 8 additions and 12 deletions

View File

@ -169,7 +169,6 @@ static CURLcode altsvc_add(struct altsvcinfo *asi, char *line)
as->prio = prio; as->prio = prio;
as->persist = persist ? 1 : 0; as->persist = persist ? 1 : 0;
Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node); Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
asi->num++; /* one more entry */
} }
} }
@ -410,7 +409,6 @@ static void altsvc_flush(struct altsvcinfo *asi, enum alpnid srcalpnid,
strcasecompare(srchost, as->src.host)) { strcasecompare(srchost, as->src.host)) {
Curl_llist_remove(&asi->list, e, NULL); Curl_llist_remove(&asi->list, e, NULL);
altsvc_free(as); altsvc_free(as);
asi->num--;
} }
} }
} }
@ -577,7 +575,6 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
as->expires = maxage + time(NULL); as->expires = maxage + time(NULL);
as->persist = persist; as->persist = persist;
Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node); Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
asi->num++; /* one more entry */
infof(data, "Added alt-svc: %s:%d over %s\n", dsthost, dstport, infof(data, "Added alt-svc: %s:%d over %s\n", dsthost, dstport,
Curl_alpnid2str(dstalpnid)); Curl_alpnid2str(dstalpnid));
} }

View File

@ -52,7 +52,6 @@ struct altsvc {
struct altsvcinfo { struct altsvcinfo {
char *filename; char *filename;
struct curl_llist list; /* list of entries */ struct curl_llist list; /* list of entries */
size_t num; /* number of alt-svc entries */
long flags; /* the publicly set bitmask */ long flags; /* the publicly set bitmask */
}; };

View File

@ -60,7 +60,7 @@ UNITTEST_START
curl = curl_easy_init(); curl = curl_easy_init();
if(!curl) if(!curl)
goto fail; goto fail;
fail_unless(asi->num == 4, "wrong number of entries"); fail_unless(asi->list.size == 4, "wrong number of entries");
msnprintf(outname, sizeof(outname), "%s-out", arg); msnprintf(outname, sizeof(outname), "%s-out", arg);
result = Curl_altsvc_parse(curl, asi, "h2=\"example.com:8080\"\r\n", result = Curl_altsvc_parse(curl, asi, "h2=\"example.com:8080\"\r\n",
@ -69,7 +69,7 @@ UNITTEST_START
fprintf(stderr, "Curl_altsvc_parse() failed!\n"); fprintf(stderr, "Curl_altsvc_parse() failed!\n");
unitfail++; unitfail++;
} }
fail_unless(asi->num == 5, "wrong number of entries"); fail_unless(asi->list.size == 5, "wrong number of entries");
result = Curl_altsvc_parse(curl, asi, "h3=\":8080\"\r\n", result = Curl_altsvc_parse(curl, asi, "h3=\":8080\"\r\n",
ALPN_h1, "2.example.org", 8080); ALPN_h1, "2.example.org", 8080);
@ -77,7 +77,7 @@ UNITTEST_START
fprintf(stderr, "Curl_altsvc_parse(2) failed!\n"); fprintf(stderr, "Curl_altsvc_parse(2) failed!\n");
unitfail++; unitfail++;
} }
fail_unless(asi->num == 6, "wrong number of entries"); fail_unless(asi->list.size == 6, "wrong number of entries");
result = Curl_altsvc_parse(curl, asi, result = Curl_altsvc_parse(curl, asi,
"h2=\"example.com:8080\", h3=\"yesyes.com\"\r\n", "h2=\"example.com:8080\", h3=\"yesyes.com\"\r\n",
@ -87,7 +87,7 @@ UNITTEST_START
unitfail++; unitfail++;
} }
/* that one should make two entries */ /* that one should make two entries */
fail_unless(asi->num == 8, "wrong number of entries"); fail_unless(asi->list.size == 8, "wrong number of entries");
result = Curl_altsvc_parse(curl, asi, result = Curl_altsvc_parse(curl, asi,
"h2=\"example.com:443\"; ma = 120;\r\n", "h2=\"example.com:443\"; ma = 120;\r\n",
@ -96,7 +96,7 @@ UNITTEST_START
fprintf(stderr, "Curl_altsvc_parse(4) failed!\n"); fprintf(stderr, "Curl_altsvc_parse(4) failed!\n");
unitfail++; unitfail++;
} }
fail_unless(asi->num == 9, "wrong number of entries"); fail_unless(asi->list.size == 9, "wrong number of entries");
/* quoted 'ma' value */ /* quoted 'ma' value */
result = Curl_altsvc_parse(curl, asi, result = Curl_altsvc_parse(curl, asi,
@ -106,7 +106,7 @@ UNITTEST_START
fprintf(stderr, "Curl_altsvc_parse(4) failed!\n"); fprintf(stderr, "Curl_altsvc_parse(4) failed!\n");
unitfail++; unitfail++;
} }
fail_unless(asi->num == 10, "wrong number of entries"); fail_unless(asi->list.size == 10, "wrong number of entries");
result = result =
Curl_altsvc_parse(curl, asi, Curl_altsvc_parse(curl, asi,
@ -116,7 +116,7 @@ UNITTEST_START
fprintf(stderr, "Curl_altsvc_parse(5) failed!\n"); fprintf(stderr, "Curl_altsvc_parse(5) failed!\n");
unitfail++; unitfail++;
} }
fail_unless(asi->num == 12, "wrong number of entries"); fail_unless(asi->list.size == 12, "wrong number of entries");
/* clear that one again and decrease the counter */ /* clear that one again and decrease the counter */
result = Curl_altsvc_parse(curl, asi, "clear;\r\n", result = Curl_altsvc_parse(curl, asi, "clear;\r\n",
@ -125,7 +125,7 @@ UNITTEST_START
fprintf(stderr, "Curl_altsvc_parse(6) failed!\n"); fprintf(stderr, "Curl_altsvc_parse(6) failed!\n");
unitfail++; unitfail++;
} }
fail_unless(asi->num == 10, "wrong number of entries"); fail_unless(asi->list.size == 10, "wrong number of entries");
Curl_altsvc_save(curl, asi, outname); Curl_altsvc_save(curl, asi, outname);