CLEANUP: mux-quic/h3: complete BUG_ON with comments

Complete each useful BUG_ON statements with a comment to explain its
purpose. Also convert BUG_ON_HOT to BUG_ON as they should not have a
big impact.

This should be backported up to 2.7.
This commit is contained in:
Amaury Denoyelle 2023-05-11 16:55:30 +02:00
parent ffdf6a32a7
commit 8d6d246dbc
2 changed files with 10 additions and 8 deletions

View File

@ -177,8 +177,8 @@ static ssize_t h3_init_uni_stream(struct h3c *h3c, struct qcs *qcs,
TRACE_ENTER(H3_EV_H3S_NEW, qcs->qcc->conn, qcs);
BUG_ON_HOT(!quic_stream_is_uni(qcs->id) ||
h3s->flags & H3_SF_UNI_INIT);
/* Function reserved to uni streams. Must be called only once per stream instance. */
BUG_ON(!quic_stream_is_uni(qcs->id) || h3s->flags & H3_SF_UNI_INIT);
ret = b_quic_dec_int(&type, b, &len);
if (!ret) {
@ -257,8 +257,8 @@ static ssize_t h3_parse_uni_stream_no_h3(struct qcs *qcs, struct buffer *b, int
{
struct h3s *h3s = qcs->ctx;
BUG_ON_HOT(!quic_stream_is_uni(qcs->id) ||
!(h3s->flags & H3_SF_UNI_NO_H3));
/* Function reserved to non-HTTP/3 unidirectional streams. */
BUG_ON(!quic_stream_is_uni(qcs->id) || !(h3s->flags & H3_SF_UNI_NO_H3));
switch (h3s->type) {
case H3S_T_QPACK_DEC:
@ -309,7 +309,8 @@ static int h3_is_frame_valid(struct h3c *h3c, struct qcs *qcs, uint64_t ftype)
struct h3s *h3s = qcs->ctx;
const uint64_t id = qcs->id;
BUG_ON_HOT(h3s->type == H3S_T_UNKNOWN);
/* Stream type must be known to ensure frame is valid for this stream. */
BUG_ON(h3s->type == H3S_T_UNKNOWN);
switch (ftype) {
case H3_FT_DATA:

View File

@ -183,7 +183,7 @@ static forceinline void qcc_reset_idle_start(struct qcc *qcc)
/* Decrement <qcc> sc. */
static forceinline void qcc_rm_sc(struct qcc *qcc)
{
BUG_ON_HOT(!qcc->nb_sc);
BUG_ON(!qcc->nb_sc); /* Ensure sc count is always valid (ie >=0). */
--qcc->nb_sc;
/* Reset qcc idle start for http-keep-alive timeout. Timeout will be
@ -196,7 +196,7 @@ static forceinline void qcc_rm_sc(struct qcc *qcc)
/* Decrement <qcc> hreq. */
static forceinline void qcc_rm_hreq(struct qcc *qcc)
{
BUG_ON_HOT(!qcc->nb_hreq);
BUG_ON(!qcc->nb_hreq); /* Ensure http req count is always valid (ie >=0). */
--qcc->nb_hreq;
/* Reset qcc idle start for http-keep-alive timeout. Timeout will be
@ -587,7 +587,8 @@ static struct qcs *qcc_init_stream_remote(struct qcc *qcc, uint64_t id)
TRACE_ENTER(QMUX_EV_QCS_NEW, qcc->conn);
BUG_ON_HOT(quic_stream_is_local(qcc, id));
/* Function reserved to remote stream IDs. */
BUG_ON(quic_stream_is_local(qcc, id));
if (quic_stream_is_bidi(id)) {
largest = &qcc->largest_bidi_r;