haproxy/src/quic_enc.c
Frederic Lecaille d5f4872ba6
Some checks are pending
Contrib / build (push) Waiting to run
alpine/musl / gcc (push) Waiting to run
VTest / Generate Build Matrix (push) Waiting to run
VTest / (push) Blocked by required conditions
Windows / Windows, gcc, all features (push) Waiting to run
TESTS: quic: useless param for b_quic_dec_int()
The third parameter passed to b_quic_dec_int() is unitialized. This is not a bug.
But this disturbs coverity for an unknown reason as revealed by GH issue #3154.

This patch takes the opportunity to use NULL as passed value to avoid using such
an uneeded third parameter.

Should be backported to 3.2 where this unit test was introduced.
2025-10-15 09:58:03 +02:00

31 lines
681 B
C

#include <haproxy/quic_enc.h>
#include <haproxy/api.h>
int quic_enc_unittest(int argc, char **argv)
{
const uint8_t init = 4;
uint64_t val = 0;
struct buffer b;
char area[12];
int ret = 1;
b = b_make(area, sizeof(area), sizeof(area) - 2, 0);
/* encode an 8-bit integer as a 4 bytes long varint */
b_putblk(&b, (char[]){0x80, 0x00, 0x00, init}, 4);
/* ensure encoded data is wrapping inside buffer */
BUG_ON(b_data(&b) != b_contig_data(&b, b_head_ofs(&b)));
/* test that b_quic_dec_int() can decode a wrapping value */
b_quic_dec_int(&val, &b, NULL);
if (val != init)
goto out;
ret = 0;
out:
return ret;
}
REGISTER_UNITTEST("quic_enc", quic_enc_unittest);