From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RB9zJ-0006x0-Qj for qemu-devel@nongnu.org; Tue, 04 Oct 2011 14:45:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RB9zI-00037m-KO for qemu-devel@nongnu.org; Tue, 04 Oct 2011 14:45:09 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:60551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RB9zI-00035u-Az for qemu-devel@nongnu.org; Tue, 04 Oct 2011 14:45:08 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e36.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p94IcEHR019288 for ; Tue, 4 Oct 2011 12:38:14 -0600 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p94Iiqvq153936 for ; Tue, 4 Oct 2011 12:44:52 -0600 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p94Iin8a021979 for ; Tue, 4 Oct 2011 12:44:51 -0600 Message-ID: <4E8B541F.8000700@linux.vnet.ibm.com> Date: Tue, 04 Oct 2011 14:44:47 -0400 From: Stefan Berger MIME-Version: 1.0 References: <20110928132255.156431784@linux.vnet.ibm.com> In-Reply-To: <20110928132255.156431784@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 7/5] Move parsing of filedescriptor into common function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: anbang.ruan@cs.ox.ac.uk, mst@redhat.com, Stefan Berger , andreas.niederl@iaik.tugraz.at, serge@hallyn.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 --- cutils.c | 12 ++++++++++++ net.c | 7 +------ qemu-common.h | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) Index: qemu-git.pt/net.c =================================================================== --- qemu-git.pt.orig/net.c +++ qemu-git.pt/net.c @@ -733,12 +733,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-common.h =================================================================== --- qemu-git.pt.orig/qemu-common.h +++ qemu-git.pt/qemu-common.h @@ -143,6 +143,7 @@ time_t mktimegm(struct tm *tm); int qemu_fls(int i); int qemu_fdatasync(int fd); int fcntl_setfl(int fd, int flag); +int qemu_parse_fd(const char *param); /* * strtosz() suffixes used to specify the default treatment of an Index: qemu-git.pt/cutils.c =================================================================== --- qemu-git.pt.orig/cutils.c +++ qemu-git.pt/cutils.c @@ -415,3 +415,15 @@ int64_t strtosz(const char *nptr, char * { return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB); } + +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; +}