eal: fix unitialized data warning
PATCH 1/1 eal: fix unitialized data warning
Valgrind reports that eal interrupt thread is calling epoll_ctl with uninitialized data. Trivial to fix by initializing it.
--- lib/librte_eal/linux/eal/eal_interrupts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/linux/eal/eal_interrupts.c +1 -1
@@ -1045,7 +1045,7 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds)static __attribute__((noreturn))void * eal_intr_thread_main(__rte_unused void *arg) { -struct epoll_event ev; +struct epoll_event ev = { };/* host thread, never break out */ for (;;) {
Signature · 1 line
2.20.1
Quoted 16 lines · Stephen Hemminger
Valgrind reports that eal interrupt thread is calling
epoll_ctlwith uninitialized data. Trivial to fix by initializing it.Fixes af75078fece3 ("first public release")Signed-off-by Stephen Hemminger <[email protected]>--- lib/librte_eal/linux/eal/eal_interrupts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/linux/eal/eal_interrupts.c +0
-0
lib/librte_eal/linux/eal/eal_interrupts.c eal_intr_handle_interrupts(int pfd, unsigned totalfds) · line 1051
Quoted 8 lines
lib/librte_eal/linux/eal/eal_interrupts.c +1
-1@@ -1045,7 +1045,7 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds)static __attribute__((noreturn))void * eal_intr_thread_main(__rte_unused void *arg) { -struct epoll_event ev; +struct epoll_event ev = { };/* host thread, never break out */ for (;;) {
typedef union epoll_data
{
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} epoll_data_t;
struct epoll_event
{
uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
} __EPOLL_PACKED;
static __attribute__((noreturn)) void *eal_intr_thread_main(__rte_unused void *arg)
{
struct epoll_event ev;
[...]
ev.events = EPOLLIN | EPOLLPRI | EPOLLRDHUP | EPOLLHUP;
ev.data.fd = src->intr_handle.fd;[...]
if (epoll_ctl(pfd, EPOLL_CTL_ADD,
src->intr_handle.fd, &ev) < 0){
So the uninitialised part is because we only set an int in the union. False positive from valgrind, but the fix is quite simple.
Signature · 1 line
David Marchand
Quoted 49 lines · On Fri, 29 Nov 2019 09:25:15 +0100 David Marchand <[email protected]>…
Quoted 16 lines · Stephen Hemminger
Valgrind reports that eal interrupt thread is calling
epoll_ctlwith uninitialized data. Trivial to fix by initializing it.Fixes af75078fece3 ("first public release")Signed-off-by Stephen Hemminger <[email protected]>--- lib/librte_eal/linux/eal/eal_interrupts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/linux/eal/eal_interrupts.c +0
-0lib/librte_eal/linux/eal/eal_interrupts.c eal_intr_handle_interrupts(int pfd, unsigned totalfds) · line 1051
Quoted 8 lines
lib/librte_eal/linux/eal/eal_interrupts.c +1
-1@@ -1045,7 +1045,7 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds)static __attribute__((noreturn))void * eal_intr_thread_main(__rte_unused void *arg) { -struct epoll_event ev; +struct epoll_event ev = { };/* host thread, never break out */ for (;;) {typedef union
epoll_data
{
void *ptr;
int fd;
uint32_tu32;
uint64_tu64;
}epoll_data_t;struct
epoll_event
{
uint32_tevents; /* Epoll events */
epoll_data_tdata; /* User data variable */
}__EPOLL_PACKED;static __attribute__((noreturn)) void *
eal_intr_thread_main(__rte_unused void *arg){ struct epoll_event ev; [...] ev.events = EPOLLIN | EPOLLPRI | EPOLLRDHUP | EPOLLHUP; ev.data.fd = src->intr_handle.fd;
Quoted 8 lines
[...]
if (epoll_ctl(pfd,EPOLL_CTL_ADD,
src->intr_handle.fd, &ev) < 0){So the uninitialised part is because we only set an int in the union. False positive from valgrind, but the fix is quite simple.
Acked-by David Marchand <[email protected]>
Agreed it is a false positive because the kernel is not going to care about the unused bits in the union. But I wanted to make the application run clean under valgrind. Otherwise, it is hard to find the real warnings in surrounding noise.
Fixed title s/unitialized/uninitialized/
Quoted 3 lines · Stephen Hemminger
Valgrind reports that eal interrupt thread is calling
epoll_ctlwith uninitialized data. Trivial to fix by initializing it.
Added a note on it being a Valgrind false positive.
Quoted 4 lines
Fixes af75078fece3 ("first public release")Signed-off-by Stephen Hemminger <[email protected]>
Applied, thanks.
--
David Marchand
Quoted 11 lines · David Marchand
Fixed title s/unitialized/uninitialized/
Quoted 3 lines · Stephen Hemminger
Valgrind reports that eal interrupt thread is calling
epoll_ctlwith uninitialized data. Trivial to fix by initializing it.Added a note on it being a Valgrind false positive.
Quoted 7 lines
Quoted 4 lines
Fixes af75078fece3 ("first public release")Signed-off-by Stephen Hemminger <[email protected]>Acked-by David Marchand <[email protected]>Applied, thanks.
It breaks build on RHEL 7.6 gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36):
lib/librte_eal/linux/eal/eal_interrupts.c: In function ‘eal_intr_thread_main’:lib/librte_eal/linux/eal/eal_interrupts.c:1048:9: error: missing initializer for field ‘events’ of ‘struct epoll_event’ [-Werror=missing-field-initializers]
struct epoll_event ev = { };
^In file included from lib/librte_eal/linu/eal/eal_interrupts.c:15:0:/usr/include/sys/epoll.h:89:12: note: ‘events’ declared here
uint32_t events; /* Epoll events */
^
Quoted 28 lines · Andrew Rybchenko
Quoted 11 lines · David Marchand
Fixed title s/unitialized/uninitialized/
Quoted 3 lines · Stephen Hemminger
Valgrind reports that eal interrupt thread is calling
epoll_ctlwith uninitialized data. Trivial to fix by initializing it.Added a note on it being a Valgrind false positive.
Quoted 7 lines
Quoted 4 lines
Fixes af75078fece3 ("first public release")Signed-off-by Stephen Hemminger <[email protected]>Acked-by David Marchand <[email protected]>Applied, thanks.
It breaks build on RHEL 7.6 gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36):
lib/librte_eal/linux/eal/eal_interrupts.c: In function ‘eal_intr_thread_main’:lib/librte_eal/linux/eal/eal_interrupts.c:1048:9: error: missing initializer for field ‘events’ of ‘struct epoll_event’ [-Werror=missing-field-initializers]
Quoted 6 lines
struct epoll_event ev = { }; ^In file included from
lib/librte_eal/linu/eal/eal_interrupts.c:15:0:/usr/include/sys/epoll.h:89:12: note: ‘events’ declared here
uint32_tevents; /* Epoll events */
^
Erf, indeed, I ran the tests on a different system than my laptop... Need more coffee, those initializers are always a pain. I'll go with a memset.
Best first commit for a release, I suppose.
--
David Marchand