From: Amaury Denoyelle Date: Thu, 19 Nov 2026 10:50:50 +0000 (+0100) Subject: BUG/MINOR: ncbuf/test: remove list dependency for standalone tests X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/gitweb.js?a=commitdiff_plain;h=17c0c6c7690b8225e7a478a6977ac1ddcfc54917;p=haproxy.git BUG/MINOR: ncbuf/test: remove list dependency for standalone tests List dependency prevents compiling ncbuf module as a standalone unit to execute unit tests. This was required for the random insertion test, where each inserted offset is saved in a list. Removes the list dependency and implements a simple single-linked list for random offsets. This fixes compilation in standalone mode. This should be backported up to 3.0. --- diff --git a/src/ncbuf.c b/src/ncbuf.c index 430d8fced..0a94c4b46 100644 --- a/src/ncbuf.c +++ b/src/ncbuf.c @@ -12,7 +12,6 @@ #include #include -#include #endif /* STANDALONE */ #ifdef DEBUG_STRICT @@ -708,9 +707,9 @@ static void ncbuf_printf(char *str, ...) } struct rand_off { - struct list el; ncb_sz_t off; ncb_sz_t len; + struct rand_off *next; }; static struct rand_off *ncb_generate_rand_off(const struct ncbuf *buf) @@ -805,8 +804,7 @@ static ncb_sz_t bufhead = 15; static int ncbuf_test(ncb_sz_t head, int reset, int print_delay) { char *data0, data1[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; - struct list list = LIST_HEAD_INIT(list); - struct rand_off *roff, *roff_tmp; + struct rand_off *roff, *roff_tmp = NULL; enum ncb_ret ret; data0 = malloc(bufsize); @@ -906,7 +904,8 @@ static int ncbuf_test(ncb_sz_t head, int reset, int print_delay) /* generate randon data offsets until the buffer is full */ while (!ncb_is_full(&b)) { roff = ncb_generate_rand_off(&b); - LIST_INSERT(&list, &roff->el); + roff->next = roff_tmp; + roff_tmp = roff; ret = ncb_add(&b, roff->off, data0, roff->len, NCB_ADD_COMPARE); BUG_ON(ret == NCB_RET_DATA_REJ); @@ -921,7 +920,7 @@ static int ncbuf_test(ncb_sz_t head, int reset, int print_delay) * At the end, the buffer should be full. */ NCB_INIT(&b); - list_for_each_entry_safe(roff, roff_tmp, &list, el) { + while (roff) { int full = ncb_is_full(&b); if (!full) { ret = ncb_add(&b, roff->off, data0, roff->len, NCB_ADD_COMPARE); @@ -930,8 +929,9 @@ static int ncbuf_test(ncb_sz_t head, int reset, int print_delay) usleep(print_delay); } - LIST_DELETE(&roff->el); + roff_tmp = roff->next; free(roff); + roff = roff_tmp; } if (!ncb_is_full(&b))