From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKfHu-00035h-9P for qemu-devel@nongnu.org; Wed, 06 Jul 2016 01:22:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKfHq-00020v-W6 for qemu-devel@nongnu.org; Wed, 06 Jul 2016 01:22:18 -0400 Received: from [59.151.112.132] (port=63170 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKfHq-00020f-Cz for qemu-devel@nongnu.org; Wed, 06 Jul 2016 01:22:14 -0400 References: <1467774199-21807-1-git-send-email-caoj.fnst@cn.fujitsu.com> From: Cao jin Message-ID: <577C970C.2040607@cn.fujitsu.com> Date: Wed, 6 Jul 2016 13:28:44 +0800 MIME-Version: 1.0 In-Reply-To: <1467774199-21807-1-git-send-email-caoj.fnst@cn.fujitsu.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] main-loop: check return value before using List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com cc Paolo again, because failed to deliver in 'git send-email' On 07/06/2016 11:03 AM, Cao jin wrote: > pointer 'qemu_aio_context' should be checked first before it is used. > qemu_bh_new() will use it. > > Also add extra newlines to make code well separated and easier to read. > > Signed-off-by: Cao jin > --- > main-loop.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/main-loop.c b/main-loop.c > index 89a6994..0d943f1 100644 > --- a/main-loop.c > +++ b/main-loop.c > @@ -154,18 +154,23 @@ int qemu_init_main_loop(Error **errp) > } > > qemu_aio_context = aio_context_new(&local_error); > - qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL); > if (!qemu_aio_context) { > error_propagate(errp, local_error); > return -EMFILE; > } > + > + qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL); > + > gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD)); > + > src = aio_get_g_source(qemu_aio_context); > g_source_attach(src, NULL); > g_source_unref(src); > + > src = iohandler_get_g_source(); > g_source_attach(src, NULL); > g_source_unref(src); > + > return 0; > } > > -- Yours Sincerely, Cao jin