From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8a9X-0000TC-S8 for qemu-devel@nongnu.org; Tue, 27 Sep 2011 12:05:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8a9T-000604-JA for qemu-devel@nongnu.org; Tue, 27 Sep 2011 12:05:03 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:42466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8a9T-0005zY-GZ for qemu-devel@nongnu.org; Tue, 27 Sep 2011 12:04:59 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e6.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p8RFeiLu018228 for ; Tue, 27 Sep 2011 11:40:44 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8RG2xqr189848 for ; Tue, 27 Sep 2011 12:03:06 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8RG2GU5003328 for ; Tue, 27 Sep 2011 13:02:17 -0300 From: Stefan Berger Content-Type: text/plain; charset="UTF-8" Date: Tue, 27 Sep 2011 12:02:07 -0400 Message-ID: <1317139327.12988.2.camel@d941e-10> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] Move filedescriptor parsing code from net.c into qemu_parse_fd() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" Cc: mst@redhat.com Move the parsing of a filedescriptor into a common function qemu_parse_fd(). Have the code in net.c call this function. Signed-off-by: Stefan Berger --- net.c | 8 ++------ qemu-char.c | 12 ++++++++++++ qemu-char.h | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) Index: qemu-git.pt/net.c =================================================================== --- qemu-git.pt.orig/net.c +++ qemu-git.pt/net.c @@ -36,6 +36,7 @@ #include "qemu_socket.h" #include "hw/qdev.h" #include "iov.h" +#include "qemu-char.h" static QTAILQ_HEAD(, VLANState) vlans; static QTAILQ_HEAD(, VLANClientState) non_vlan_clients; @@ -733,12 +734,7 @@ int net_handle_fd_param(Monitor *mon, co return -1; } } else { - char *endptr = NULL; - - fd = strtol(param, &endptr, 10); - if (*endptr || (fd == 0 && param == endptr)) { - return -1; - } + fd = qemu_parse_fd(param); } return fd; Index: qemu-git.pt/qemu-char.c =================================================================== --- qemu-git.pt.orig/qemu-char.c +++ qemu-git.pt/qemu-char.c @@ -2692,3 +2692,15 @@ CharDriverState *qemu_chr_find(const cha } return NULL; } + +int qemu_parse_fd(const char *param) +{ + int fd; + char *endptr = NULL; + + fd = strtol(param, &endptr, 10); + if (*endptr || (fd == 0 && param == endptr)) { + return -1; + } + return fd; +} Index: qemu-git.pt/qemu-char.h =================================================================== --- qemu-git.pt.orig/qemu-char.h +++ qemu-git.pt/qemu-char.h @@ -248,4 +248,6 @@ int qemu_set_fd_handler(int fd, IOHandler *fd_read, IOHandler *fd_write, void *opaque); + +int qemu_parse_fd(const char *param); #endif