BUILD: quic+h3: 32-bit compilation errors fixes
In GH #1760 (which is marked as being a feature), there were compilation
errors on MacOS which could be reproduced in Linux when building 32-bit code
(-m32 gcc option). Most of them were due to variables types mixing in QUIC_MIN macro
or using size_t type in place of uint64_t type.
Must be backported to 2.6.
diff --git a/include/haproxy/quic_enc.h b/include/haproxy/quic_enc.h
index 169845a..1fddab7 100644
--- a/include/haproxy/quic_enc.h
+++ b/include/haproxy/quic_enc.h
@@ -89,7 +89,7 @@
}
/* Returns the maximum integer which may be encoded with <size> bytes */
-static inline size_t quic_max_int_by_size(int size)
+static inline uint64_t quic_max_int_by_size(int size)
{
switch (size) {
case 1:
diff --git a/src/h3.c b/src/h3.c
index 797d4f2..c15adf0 100644
--- a/src/h3.c
+++ b/src/h3.c
@@ -1143,7 +1143,7 @@
chunk_appendf(&trace_buf, " : qcc=%p(F)", qcc);
if (qcs)
- chunk_appendf(&trace_buf, " qcs=%p(%lu)", qcs, qcs->id);
+ chunk_appendf(&trace_buf, " qcs=%p(%llu)", qcs, (ull)qcs->id);
}
}
diff --git a/src/mux_quic.c b/src/mux_quic.c
index 9449b86..0f85bbd 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -1672,13 +1672,13 @@
{
switch (frm->type) {
case QUIC_FT_MAX_STREAMS_BIDI:
- chunk_appendf(&trace_buf, " max_streams=%lu",
- frm->max_streams_bidi.max_streams);
+ chunk_appendf(&trace_buf, " max_streams=%llu",
+ (ull)frm->max_streams_bidi.max_streams);
break;
case QUIC_FT_MAX_STREAMS_UNI:
- chunk_appendf(&trace_buf, " max_streams=%lu",
- frm->max_streams_uni.max_streams);
+ chunk_appendf(&trace_buf, " max_streams=%llu",
+ (ull)frm->max_streams_uni.max_streams);
break;
default:
@@ -1703,11 +1703,11 @@
chunk_appendf(&trace_buf, " : qcc=%p(F)", qcc);
if (qcs)
- chunk_appendf(&trace_buf, " qcs=%p(%lu)", qcs, qcs->id);
+ chunk_appendf(&trace_buf, " qcs=%p(%llu)", qcs, (ull)qcs->id);
if (mask & QMUX_EV_QCC_NQCS) {
const uint64_t *id = a3;
- chunk_appendf(&trace_buf, " id=%lu", *id);
+ chunk_appendf(&trace_buf, " id=%llu", (ull)*id);
}
if (mask & QMUX_EV_SEND_FRM)
@@ -1715,14 +1715,14 @@
if (mask & QMUX_EV_QCS_XFER_DATA) {
const struct qcs_xfer_data_trace_arg *arg = a3;
- chunk_appendf(&trace_buf, " prep=%lu xfer=%d",
- arg->prep, arg->xfer);
+ chunk_appendf(&trace_buf, " prep=%llu xfer=%d",
+ (ull)arg->prep, arg->xfer);
}
if (mask & QMUX_EV_QCS_BUILD_STRM) {
const struct qcs_build_stream_trace_arg *arg = a3;
- chunk_appendf(&trace_buf, " len=%lu fin=%d offset=%lu",
- arg->len, arg->fin, arg->offset);
+ chunk_appendf(&trace_buf, " len=%llu fin=%d offset=%llu",
+ (ull)arg->len, arg->fin, (ull)arg->offset);
}
}
}
diff --git a/src/qpack-dec.c b/src/qpack-dec.c
index 09ec66d..085cf2f 100644
--- a/src/qpack-dec.c
+++ b/src/qpack-dec.c
@@ -162,7 +162,7 @@
* Return a negative error if failed, 0 if not.
*/
static int qpack_decode_fs_pfx(uint64_t *enc_ric, uint64_t *db, int *sign_bit,
- const unsigned char **raw, size_t *len)
+ const unsigned char **raw, uint64_t *len)
{
*enc_ric = qpack_get_varint(raw, len, 8);
if (*len == (uint64_t)-1)
@@ -184,7 +184,7 @@
* Returns the number of headers inserted into list excluding the end marker.
* In case of error, a negative code QPACK_ERR_* is returned.
*/
-int qpack_decode_fs(const unsigned char *raw, size_t len, struct buffer *tmp,
+int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
struct http_hdr *list, int list_size)
{
struct ist name, value;
diff --git a/src/quic_frame.c b/src/quic_frame.c
index 5a13e52..386c409 100644
--- a/src/quic_frame.c
+++ b/src/quic_frame.c
@@ -189,7 +189,7 @@
case QUIC_FT_CONNECTION_CLOSE:
{
const struct quic_connection_close *cc = &frm->connection_close;
- size_t plen = QUIC_MIN(cc->reason_phrase_len, sizeof cc->reason_phrase);
+ size_t plen = QUIC_MIN((size_t)cc->reason_phrase_len, sizeof cc->reason_phrase);
chunk_appendf(&trace_buf,
" error_code=%llu frame_type=%llu reason_phrase_len=%llu",
(ull)cc->error_code, (ull)cc->frame_type,
@@ -201,7 +201,7 @@
case QUIC_FT_CONNECTION_CLOSE_APP:
{
const struct quic_connection_close_app *cc = &frm->connection_close_app;
- size_t plen = QUIC_MIN(cc->reason_phrase_len, sizeof cc->reason_phrase);
+ size_t plen = QUIC_MIN((size_t)cc->reason_phrase_len, sizeof cc->reason_phrase);
chunk_appendf(&trace_buf,
" error_code=%llu reason_phrase_len=%llu",
(ull)cc->error_code, (ull)cc->reason_phrase_len);
@@ -925,7 +925,7 @@
end - *buf < cc->reason_phrase_len)
return 0;
- plen = QUIC_MIN(cc->reason_phrase_len, sizeof cc->reason_phrase);
+ plen = QUIC_MIN((size_t)cc->reason_phrase_len, sizeof cc->reason_phrase);
memcpy(cc->reason_phrase, *buf, plen);
*buf += cc->reason_phrase_len;
@@ -969,7 +969,7 @@
end - *buf < cc->reason_phrase_len)
return 0;
- plen = QUIC_MIN(cc->reason_phrase_len, sizeof cc->reason_phrase);
+ plen = QUIC_MIN((size_t)cc->reason_phrase_len, sizeof cc->reason_phrase);
memcpy(cc->reason_phrase, *buf, plen);
*buf += cc->reason_phrase_len;
diff --git a/src/xprt_quic.c b/src/xprt_quic.c
index f7ac1c9..e55507d 100644
--- a/src/xprt_quic.c
+++ b/src/xprt_quic.c
@@ -2754,7 +2754,7 @@
/* Leave room for the datagram header */
pos += dg_headlen;
if (!quic_peer_validated_addr(qc) && qc_is_listener(qc)) {
- end = pos + QUIC_MIN(qc->path->mtu, 3 * qc->rx.bytes - qc->tx.prep_bytes);
+ end = pos + QUIC_MIN((uint64_t)qc->path->mtu, 3 * qc->rx.bytes - qc->tx.prep_bytes);
}
else {
end = pos + qc->path->mtu;
@@ -2881,7 +2881,7 @@
/* Leave room for the datagram header */
pos += dg_headlen;
if (!quic_peer_validated_addr(qc) && qc_is_listener(qc)) {
- end = pos + QUIC_MIN(qc->path->mtu, 3 * qc->rx.bytes - qc->tx.prep_bytes);
+ end = pos + QUIC_MIN((uint64_t)qc->path->mtu, 3 * qc->rx.bytes - qc->tx.prep_bytes);
}
else {
end = pos + qc->path->mtu;
@@ -5898,7 +5898,7 @@
flen = hlen + dlen_sz + dlen;
}
else {
- dlen = QUIC_MIN(avail_room, cf->stream.len);
+ dlen = QUIC_MIN((uint64_t)avail_room, cf->stream.len);
flen = hlen + dlen;
}
TRACE_PROTO(" STREAM data length (hlen, stream.len, dlen)",