From patchwork Wed Sep 7 10:45:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 113737 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4054FB6F8F for ; Wed, 7 Sep 2011 20:45:45 +1000 (EST) Received: from localhost ([::1]:52193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1FdW-00077x-CZ for incoming@patchwork.ozlabs.org; Wed, 07 Sep 2011 06:45:42 -0400 Received: from eggs.gnu.org ([140.186.70.92]:54894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1FdP-00077g-W9 for qemu-devel@nongnu.org; Wed, 07 Sep 2011 06:45:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1FdO-0000aY-Hq for qemu-devel@nongnu.org; Wed, 07 Sep 2011 06:45:35 -0400 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:43040) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1FdN-0000aJ-Kg for qemu-devel@nongnu.org; Wed, 07 Sep 2011 06:45:34 -0400 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp02.in.ibm.com (8.14.4/8.13.1) with ESMTP id p87AjU1G020316 for ; Wed, 7 Sep 2011 16:15:30 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p87AjUwi4456526 for ; Wed, 7 Sep 2011 16:15:30 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p87AjTta012041 for ; Wed, 7 Sep 2011 16:15:30 +0530 Received: from skywalker.in.ibm.com ([9.124.35.129]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p87AjT9t012035; Wed, 7 Sep 2011 16:15:29 +0530 From: "Aneesh Kumar K.V" To: qemu-devel@nongnu.org Date: Wed, 7 Sep 2011 16:15:28 +0530 Message-Id: <1315392328-25317-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 122.248.162.2 Cc: aliguori@us.ibm.com, "Aneesh Kumar K.V" Subject: [Qemu-devel] [PATCH] iohandler: update qemu_fd_set_handler to work with null call back arg X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Many users of qemu_fd_set_handler including VirtFS use NULL call back arg. Update fd_trampoline and qemu_fd_set_handler to work with NULL call back arg Signed-off-by: Aneesh Kumar K.V --- iohandler.c | 31 ++++++++++++------------------- 1 files changed, 12 insertions(+), 19 deletions(-) diff --git a/iohandler.c b/iohandler.c index 5ef66fb..b803208 100644 --- a/iohandler.c +++ b/iohandler.c @@ -93,10 +93,6 @@ static gboolean fd_trampoline(GIOChannel *chan, GIOCondition cond, gpointer opaq { IOTrampoline *tramp = opaque; - if (tramp->opaque == NULL) { - return FALSE; - } - if ((cond & G_IO_IN) && tramp->fd_read) { tramp->fd_read(tramp->opaque); } @@ -113,6 +109,7 @@ int qemu_set_fd_handler(int fd, IOHandler *fd_write, void *opaque) { + GIOCondition cond = 0; static IOTrampoline fd_trampolines[FD_SETSIZE]; IOTrampoline *tramp = &fd_trampolines[fd]; @@ -121,25 +118,21 @@ int qemu_set_fd_handler(int fd, g_source_remove(tramp->tag); } - if (opaque) { - GIOCondition cond = 0; - - tramp->fd_read = fd_read; - tramp->fd_write = fd_write; - tramp->opaque = opaque; - - if (fd_read) { - cond |= G_IO_IN | G_IO_ERR; - } + tramp->fd_read = fd_read; + tramp->fd_write = fd_write; + tramp->opaque = opaque; - if (fd_write) { - cond |= G_IO_OUT | G_IO_ERR; - } + if (fd_read) { + cond |= G_IO_IN | G_IO_ERR; + } - tramp->chan = g_io_channel_unix_new(fd); - tramp->tag = g_io_add_watch(tramp->chan, cond, fd_trampoline, tramp); + if (fd_write) { + cond |= G_IO_OUT | G_IO_ERR; } + tramp->chan = g_io_channel_unix_new(fd); + tramp->tag = g_io_add_watch(tramp->chan, cond, fd_trampoline, tramp); + return 0; }