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.
diff --git a/src/h3.c b/src/h3.c
index 59e57c2..bff31c9 100644
--- a/src/h3.c
+++ b/src/h3.c
@@ -177,8 +177,8 @@
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 @@
{
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 @@
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:
diff --git a/src/mux_quic.c b/src/mux_quic.c
index c4b6957..24a5279 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -183,7 +183,7 @@
/* 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 @@
/* 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 @@
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;