* [PATCH 1/2] kvm tools: Zero out event before calling epoll_ctl()
@ 2011-12-06 12:15 Sasha Levin
2011-12-06 12:15 ` [PATCH 2/2] kvm tools: Initialize irq_routing before using it Sasha Levin
2011-12-06 12:38 ` [PATCH 1/2] kvm tools: Zero out event before calling epoll_ctl() Ingo Molnar
0 siblings, 2 replies; 3+ messages in thread
From: Sasha Levin @ 2011-12-06 12:15 UTC (permalink / raw)
To: penberg; +Cc: mingo, gorcunov, asias.hejun, kvm, Sasha Levin
Zero out struct epoll_event before calling epoll_ctl(). This isn't really
required, but is done to avoid warnings.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/kvm-ipc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/kvm/kvm-ipc.c b/tools/kvm/kvm-ipc.c
index 40ab457..68c2565 100644
--- a/tools/kvm/kvm-ipc.c
+++ b/tools/kvm/kvm-ipc.c
@@ -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;
--
1.7.8
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] kvm tools: Initialize irq_routing before using it
2011-12-06 12:15 [PATCH 1/2] kvm tools: Zero out event before calling epoll_ctl() Sasha Levin
@ 2011-12-06 12:15 ` Sasha Levin
2011-12-06 12:38 ` [PATCH 1/2] kvm tools: Zero out event before calling epoll_ctl() Ingo Molnar
1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2011-12-06 12:15 UTC (permalink / raw)
To: penberg; +Cc: mingo, gorcunov, asias.hejun, kvm, Sasha Levin
Initialize irq_routing, and specifically irq_routing->nr before using it.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/x86/irq.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/kvm/x86/irq.c b/tools/kvm/x86/irq.c
index 1392dfb..b8a7257 100644
--- a/tools/kvm/x86/irq.c
+++ b/tools/kvm/x86/irq.c
@@ -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");
--
1.7.8
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] kvm tools: Zero out event before calling epoll_ctl()
2011-12-06 12:15 [PATCH 1/2] kvm tools: Zero out event before calling epoll_ctl() Sasha Levin
2011-12-06 12:15 ` [PATCH 2/2] kvm tools: Initialize irq_routing before using it Sasha Levin
@ 2011-12-06 12:38 ` Ingo Molnar
1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2011-12-06 12:38 UTC (permalink / raw)
To: Sasha Levin; +Cc: penberg, gorcunov, asias.hejun, kvm
* Sasha Levin <levinsasha928@gmail.com> wrote:
> Zero out struct epoll_event before calling epoll_ctl(). This isn't really
> required, but is done to avoid warnings.
>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
> tools/kvm/kvm-ipc.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/tools/kvm/kvm-ipc.c b/tools/kvm/kvm-ipc.c
> index 40ab457..68c2565 100644
> --- a/tools/kvm/kvm-ipc.c
> +++ b/tools/kvm/kvm-ipc.c
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-12-06 12:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-06 12:15 [PATCH 1/2] kvm tools: Zero out event before calling epoll_ctl() Sasha Levin
2011-12-06 12:15 ` [PATCH 2/2] kvm tools: Initialize irq_routing before using it Sasha Levin
2011-12-06 12:38 ` [PATCH 1/2] kvm tools: Zero out event before calling epoll_ctl() Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).