summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorVladimir Homutov <vl@nginx.com>2020-04-23 12:10:56 +0300
committerVladimir Homutov <vl@nginx.com>2020-04-23 12:10:56 +0300
commit936f577967f6436fbe719274a1896fb4f0a1a9b5 (patch)
treed66109d05e860ccb50857163ac410f1cf9ed5011 /src
parente34161c3d52f84ec9a07bcf7bb94e1ac5a81ce63 (diff)
downloadnginx-936f577967f6436fbe719274a1896fb4f0a1a9b5.tar.gz
nginx-936f577967f6436fbe719274a1896fb4f0a1a9b5.tar.bz2
Retired the ngx_quic_parse_int_multi() function.
It used variable-length arguments what is not really necessary.
Diffstat (limited to 'src')
-rw-r--r--src/event/ngx_event_quic_transport.c111
1 files changed, 56 insertions, 55 deletions
diff --git a/src/event/ngx_event_quic_transport.c b/src/event/ngx_event_quic_transport.c
index fdaf8b88e..546a25168 100644
--- a/src/event/ngx_event_quic_transport.c
+++ b/src/event/ngx_event_quic_transport.c
@@ -57,7 +57,6 @@
static u_char *ngx_quic_parse_int(u_char *pos, u_char *end, uint64_t *out);
-static u_char *ngx_quic_parse_int_multi(u_char *pos, u_char *end, ...);
static void ngx_quic_build_int(u_char **pos, uint64_t value);
static u_char *ngx_quic_read_uint8(u_char *pos, u_char *end, uint8_t *value);
@@ -139,36 +138,6 @@ ngx_quic_parse_int(u_char *pos, u_char *end, uint64_t *out)
static ngx_inline u_char *
-ngx_quic_parse_int_multi(u_char *pos, u_char *end, ...)
-{
- u_char *p;
- va_list ap;
- uint64_t *item;
-
- p = pos;
-
- va_start(ap, end);
-
- do {
- item = va_arg(ap, uint64_t *);
- if (item == NULL) {
- break;
- }
-
- p = ngx_quic_parse_int(p, end, item);
- if (p == NULL) {
- return NULL;
- }
-
- } while (1);
-
- va_end(ap);
-
- return p;
-}
-
-
-static ngx_inline u_char *
ngx_quic_read_uint8(u_char *pos, u_char *end, uint8_t *value)
{
if ((size_t)(end - pos) < 1) {
@@ -621,10 +590,11 @@ ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end,
goto not_allowed;
}
- p = ngx_quic_parse_int_multi(p, end, &f->u.ack.largest,
- &f->u.ack.delay, &f->u.ack.range_count,
- &f->u.ack.first_range, NULL);
- if (p == NULL) {
+ if (!((p = ngx_quic_parse_int(p, end, &f->u.ack.largest))
+ && (p = ngx_quic_parse_int(p, end, &f->u.ack.delay))
+ && (p = ngx_quic_parse_int(p, end, &f->u.ack.range_count))
+ && (p = ngx_quic_parse_int(p, end, &f->u.ack.first_range))))
+ {
ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
"failed to parse ack frame");
return NGX_ERROR;
@@ -634,7 +604,12 @@ ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end,
/* process all ranges to get bounds, values are ignored */
for (i = 0; i < f->u.ack.range_count; i++) {
- p = ngx_quic_parse_int_multi(p, end, &varint, &varint, NULL);
+
+ p = ngx_quic_parse_int(p, end, &varint);
+ if (p) {
+ p = ngx_quic_parse_int(p, end, &varint);
+ }
+
if (p == NULL) {
ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
"failed to parse ack frame range %ui", i);
@@ -653,9 +628,10 @@ ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end,
if (f->type == NGX_QUIC_FT_ACK_ECN) {
- p = ngx_quic_parse_int_multi(p, end, &f->u.ack.ect0,
- &f->u.ack.ect1, &f->u.ack.ce, NULL);
- if (p == NULL) {
+ if (!((p = ngx_quic_parse_int(p, end, &f->u.ack.ect0))
+ && (p = ngx_quic_parse_int(p, end, &f->u.ack.ect1))
+ && (p = ngx_quic_parse_int(p, end, &f->u.ack.ce))))
+ {
ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
"failed to parse ack frame ECT counts", i);
return NGX_ERROR;
@@ -680,11 +656,17 @@ ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end,
goto not_allowed;
}
- p = ngx_quic_parse_int_multi(p, end, &f->u.ncid.seqnum,
- &f->u.ncid.retire, NULL);
+ p = ngx_quic_parse_int(p, end, &f->u.ncid.seqnum);
if (p == NULL) {
ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
- "failed to parse new connection id frame");
+ "failed to parse new connection id frame seqnum");
+ return NGX_ERROR;
+ }
+
+ p = ngx_quic_parse_int(p, end, &f->u.ncid.retire);
+ if (p == NULL) {
+ ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
+ "failed to parse new connection id frame retire");
return NGX_ERROR;
}
@@ -871,10 +853,11 @@ ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end,
goto not_allowed;
}
- p = ngx_quic_parse_int_multi(p, end, &f->u.reset_stream.id,
- &f->u.reset_stream.error_code,
- &f->u.reset_stream.final_size, NULL);
- if (p == NULL) {
+ if (!((p = ngx_quic_parse_int(p, end, &f->u.reset_stream.id))
+ && (p = ngx_quic_parse_int(p, end, &f->u.reset_stream.error_code))
+ && (p = ngx_quic_parse_int(p, end,
+ &f->u.reset_stream.final_size))))
+ {
ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
"failed to parse reset stream frame");
return NGX_ERROR;
@@ -893,11 +876,17 @@ ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end,
goto not_allowed;
}
- p = ngx_quic_parse_int_multi(p, end, &f->u.stop_sending.id,
- &f->u.stop_sending.error_code, NULL);
+ p = ngx_quic_parse_int(p, end, &f->u.stop_sending.id);
+ if (p == NULL) {
+ ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
+ "failed to parse stop sending frame id");
+ return NGX_ERROR;
+ }
+
+ p = ngx_quic_parse_int(p, end, &f->u.stop_sending.error_code);
if (p == NULL) {
ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
- "failed to parse stop sending frame");
+ "failed to parse stop sending frame error code");
return NGX_ERROR;
}
@@ -976,11 +965,17 @@ ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end,
goto not_allowed;
}
- p = ngx_quic_parse_int_multi(p, end, &f->u.max_stream_data.id,
- &f->u.max_stream_data.limit, NULL);
+ p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.id);
if (p == NULL) {
ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
- "failed to parse max stream data frame");
+ "failed to parse max stream data frame data id");
+ return NGX_ERROR;
+ }
+
+ p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.limit);
+ if (p == NULL) {
+ ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
+ "failed to parse max stream data frame data limit");
return NGX_ERROR;
}
@@ -1014,11 +1009,17 @@ ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end,
goto not_allowed;
}
- p = ngx_quic_parse_int_multi(p, end, &f->u.stream_data_blocked.id,
- &f->u.stream_data_blocked.limit, NULL);
+ p = ngx_quic_parse_int(p, end, &f->u.stream_data_blocked.id);
+ if (p == NULL) {
+ ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
+ "failed to parse tream data blocked frame id");
+ return NGX_ERROR;
+ }
+
+ p = ngx_quic_parse_int(p, end, &f->u.stream_data_blocked.limit);
if (p == NULL) {
ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
- "failed to parse tream data blocked frame");
+ "failed to parse tream data blocked frame limit");
return NGX_ERROR;
}