From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDgDU-0000o5-UR for qemu-devel@nongnu.org; Tue, 11 Oct 2011 13:34:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDgDS-0001FZ-B4 for qemu-devel@nongnu.org; Tue, 11 Oct 2011 13:34:12 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:54236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDgDS-0001F4-0Z for qemu-devel@nongnu.org; Tue, 11 Oct 2011 13:34:10 -0400 Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 11 Oct 2011 11:34:08 -0600 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9BHXASs069018 for ; Tue, 11 Oct 2011 11:33:13 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9BHX8QD029643 for ; Tue, 11 Oct 2011 11:33:09 -0600 Message-Id: <20111011173307.151325846@linux.vnet.ibm.com> Date: Tue, 11 Oct 2011 13:32:23 -0400 From: Stefan Berger References: <20111011173216.247822737@linux.vnet.ibm.com> Content-Disposition: inline; filename=qemu_parse_fd.diff Subject: [Qemu-devel] [PATCH V12 7/8] Move parsing of filedescriptor into common function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: stefanb@linux.vnet.ibm.com, qemu-devel@nongnu.org Cc: mst@redhat.com, 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; +}