From: Frederic Lecaille Date: Wed, 4 Nov 2026 16:05:24 +0000 (+0100) Subject: CLEANUP: quic: compute the STREAM frame end offset once in qc_stream_frm_is_acked() X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=2e8fbbf87e3f834bb5af9adb44c382ba0f29b606;p=haproxy.git CLEANUP: quic: compute the STREAM frame end offset once in qc_stream_frm_is_acked() The end offset of a STREAM frame, frm->offset + frm->len, was recomputed four times in qc_stream_frm_is_acked(): once in the BUG_ON() and three times in the offset comparisons. Store it in a local frm_end variable, as already done for the FIN bit flag. No functional change, no need to backport. --- diff --git a/src/quic_retransmit.c b/src/quic_retransmit.c index f4d12e180..891532240 100644 --- a/src/quic_retransmit.c +++ b/src/quic_retransmit.c @@ -21,6 +21,7 @@ int qc_stream_frm_is_acked(struct quic_conn *qc, struct quic_frame *f) { const struct qf_stream *frm = &f->stream; const struct qc_stream_desc *s = frm->stream; + const uint64_t frm_end = frm->offset + frm->len; const int frm_fin = f->type & QUIC_STREAM_FRAME_TYPE_FIN_BIT; if (!eb64_lookup(&qc->streams_by_id, frm->id)) { @@ -29,17 +30,17 @@ int qc_stream_frm_is_acked(struct quic_conn *qc, struct quic_frame *f) } /* Frame cannot advertise FIN for a smaller data range. */ - BUG_ON(frm_fin && frm->offset + frm->len < s->ack_offset); + BUG_ON(frm_fin && frm_end < s->ack_offset); - if (frm->offset + frm->len < s->ack_offset || - (frm->offset + frm->len == s->ack_offset && + if (frm_end < s->ack_offset || + (frm_end == s->ack_offset && (!frm_fin || !(s->flags & QC_SD_FL_WAIT_FOR_FIN)))) { TRACE_DEVEL("STREAM frame already acked : fully acked range", QUIC_EV_CONN_PRSAFRM, qc, f); return 1; } if (frm->offset < s->ack_offset && - frm->offset + frm->len > s->ack_offset) { + frm_end > s->ack_offset) { /* Data range partially acked, remove it from STREAM frame. */ const uint64_t diff = s->ack_offset - frm->offset; TRACE_DEVEL("updated partially acked frame", QUIC_EV_CONN_PRSAFRM, qc, f);