From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8raK-0000vt-BP for qemu-devel@nongnu.org; Wed, 28 Sep 2011 06:41:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8raJ-0000Jj-6i for qemu-devel@nongnu.org; Wed, 28 Sep 2011 06:41:52 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:60514) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8raI-0000JO-Vf for qemu-devel@nongnu.org; Wed, 28 Sep 2011 06:41:51 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e34.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p8SAfnXh020897 for ; Wed, 28 Sep 2011 04:41:49 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8SAfn3v156052 for ; Wed, 28 Sep 2011 04:41:49 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8SAfnAO029866 for ; Wed, 28 Sep 2011 04:41:49 -0600 From: Stefan Berger Content-Type: text/plain; charset="UTF-8" Date: Wed, 28 Sep 2011 06:41:32 -0400 Message-ID: <1317206492.21121.3.camel@d941e-10> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH v2] 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: stefanha@gmail.com, mst@redhat.com Move the parsing of a filedescriptor into a common function qemu_parse_fd() so others can use it as well. Have net.c call this function. v2: - moving qemu_parse_fd into cutils.c 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; +}