ring: fix build for gcc O1 optimization
Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using
gcc (GCC) 9.3.1
20200408 (Red Hat 9.3.1-2)
Two build errors:
1)
In file included from .../build/include/rte_ring_elem.h:1093,
from .../lib/librte_rcu/rte_rcu_qsbr.c:21:
../lib/librte_rcu/rte_rcu_qsbr.c: In function ‘rte_rcu_qsbr_dq_reclaim’:
.../build/include/rte_ring_peek.h:282:22:
error: ‘avail’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
282 | *available = avail - n;
| ~~~~~~^~~
./build/include/rte_ring_peek.h:259:11: note: ‘avail’ was declared here
259 | uint32_t avail, head, next;
| ^~~~~
2)
In file included from .../build/include/rte_ring_elem.h:1093,
from .../build/include/rte_ring.h:405,
from .../app/test/test_ring_stress.h:13,
from .../app/test/test_ring_stress_impl.h:5,
from .../app/test/test_ring_peek_stress.c:5:
.../app/test/test_ring_peek_stress.c: In function ‘_st_ring_enqueue_bulk’:
.../build/include/rte_ring_peek.h:80:22:
error: ‘free’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
80 | *free_space = free - n;
| ~~~~~^~~
.../build/include/rte_ring_peek.h:60:11: note: ‘free’ was declared here
60 | uint32_t free, head, next;
| ^~~~
The cases shouldn't be hit, and it looks like there is already logic
error if it has been hit, but assigning 'avail' & 'free' to '0' to fix
the build error.
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>