Skip to content

Commit eab3a31

Browse files
Andre Muezeriedavid-marchand
Andre Muezerie
authored andcommitted
rcu: remove VLAs
There are two lines that were using VLAs, which are not supported by MSVC. 1) ../lib/rcu/rte_rcu_qsbr.c:326:12: warning: variable length array used [-Wvla] 326 | char data[dq->esize]; | ^~~~~~~~~ 2) ../lib/rcu/rte_rcu_qsbr.c:389:12: warning: variable length array used [-Wvla] 389 | char data[dq->esize]; | ^~~~~~~~~ The short-term fix is to use alloca, to allow progress with the msvc compatibility work. The long-term plan involves API changes and therefore can only be applied with a new release. This long-term plan consists of introducing some reasonable limitation on RCU DQ element size. Signed-off-by: Andre Muezerie <[email protected]>
1 parent d25fdf4 commit eab3a31

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

lib/rcu/meson.build

-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,3 @@ sources = files('rte_rcu_qsbr.c')
1111
headers = files('rte_rcu_qsbr.h')
1212

1313
deps += ['ring']
14-
15-
# FIXME: this library was enabled for mingw target (a Windows target).
16-
# Relying on no_wvla_cflag would trigger a build error until the VLA in rte_rcu_qsbr.c is removed.
17-
# Disable the warning here for now.
18-
if cc.has_argument('-Wvla')
19-
cflags += '-Wno-vla'
20-
endif

lib/rcu/rte_rcu_qsbr.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e)
331331
return 1;
332332
}
333333

334-
char data[dq->esize];
334+
char *data = alloca(dq->esize);
335335
dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data;
336336
/* Start the grace period */
337337
dq_elem->token = rte_rcu_qsbr_start(dq->v);
@@ -395,10 +395,10 @@ rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, unsigned int n,
395395

396396
cnt = 0;
397397

398-
char data[dq->esize];
398+
char *data = alloca(dq->esize);
399399
/* Check reader threads quiescent state and reclaim resources */
400400
while (cnt < n &&
401-
rte_ring_dequeue_bulk_elem_start(dq->r, &data,
401+
rte_ring_dequeue_bulk_elem_start(dq->r, data,
402402
dq->esize, 1, available) != 0) {
403403
dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data;
404404

0 commit comments

Comments
 (0)