kvm tools: Zero out event before calling epoll_ctl()
PATCH 1/2 kvm tools: Zero out event before calling epoll_ctl()
Zero out struct epoll_event before calling epoll_ctl(). This isn't really required, but is done to avoid warnings.
--- tools/kvm/kvm-ipc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/kvm/kvm-ipc.c +1 -1
@@ -132,7 +132,7 @@ static void *kvm_ipc__thread(void *param)int kvm_ipc__start (int sock) { -struct epoll_event ev; +struct epoll_event ev = {0 }; server_fd = sock;
Signature · 1 line
1.7.8
PATCH 2/2 kvm tools: Initialize irq_routing before using it
Initialize irq_routing, and specifically irq_routing->nr before using it.
--- tools/kvm/x86/irq.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
tools/kvm/x86/irq.c +2 -2
@@ -140,8 +140,8 @@ void irq__init(struct kvm *kvm) {int i, r; - irq_routing =malloc (sizeof (struct kvm_irq_routing ) + -IRQ_MAX_GSI *sizeof (struct kvm_irq_routing_entry )); + irq_routing =calloc (sizeof (struct kvm_irq_routing ) + +IRQ_MAX_GSI *sizeof (struct kvm_irq_routing_entry ),1 );if (irq_routing ==NULL )die ("Failed allocating space for GSI table" );
Signature · 1 line
1.7.8
Quoted 13 lines · Sasha Levin
Zero out struct
epoll_eventbefore callingepoll_ctl(). This isn't really required, but is done to avoid warnings.Signed-off-by Sasha Levin <[email protected]>--- tools/kvm/kvm-ipc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)tools/kvm/kvm-ipc.c +0
-0
tools/kvm/kvm-ipc.c static void *kvm_ipc__thread(void *param) · line 137
Quoted 7 lines
tools/kvm/kvm-ipc.c +1
-1@@ -132,7 +132,7 @@ static void *kvm_ipc__thread(void *param)int kvm_ipc__start (int sock) { -struct epoll_event ev; +struct epoll_event ev = {0 }; server_fd = sock;
While it is true that epoll_ctl() currently ignores certain fields so we could leave them uninitialized but generally it's very good practice to only pass in well-defined values to kernel syscalls, so the zeroing is a quality of implementation issue as well, not just a Valgrind warning fix.
Thanks,
Ingo