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.
This commit is contained in:
Frédéric Lécaille 2022-06-24 12:13:53 +02:00
parent 2bed1f166e
commit 628e89cfae
6 changed files with 21 additions and 21 deletions

View File

@ -89,7 +89,7 @@ static inline size_t quic_int_getsize(uint64_t val)
}
/* 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:

View File

@ -1143,7 +1143,7 @@ static void h3_trace(enum trace_level level, uint64_t mask,
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);
}
}

View File

@ -1672,13 +1672,13 @@ static void qmux_trace_frm(const struct quic_frame *frm)
{
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 @@ static void qmux_trace(enum trace_level level, uint64_t mask,
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 @@ static void qmux_trace(enum trace_level level, uint64_t mask,
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);
}
}
}

View File

@ -162,7 +162,7 @@ int qpack_decode_dec(struct buffer *buf, void *ctx)
* 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 @@ static int qpack_decode_fs_pfx(uint64_t *enc_ric, uint64_t *db, int *sign_bit,
* 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;

View File

@ -189,7 +189,7 @@ void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm)
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 @@ void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm)
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 @@ static int quic_parse_connection_close_frame(struct quic_frame *frm, struct quic
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 @@ static int quic_parse_connection_close_app_frame(struct quic_frame *frm, struct
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;

View File

@ -2754,7 +2754,7 @@ static int qc_prep_app_pkts(struct quic_conn *qc, struct qring *qr,
/* 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 @@ static int qc_prep_pkts(struct quic_conn *qc, struct qring *qr,
/* 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 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
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)",