From patchwork Tue Oct 11 17:32:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 119027 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 7D441B6F67 for ; Wed, 12 Oct 2011 04:34:35 +1100 (EST) Received: from localhost ([::1]:51024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDgDp-0001PC-0N for incoming@patchwork.ozlabs.org; Tue, 11 Oct 2011 13:34:33 -0400 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 d03relay05.boulder.ibm.com ([9.17.195.107]) by e35.co.us.ibm.com ([192.168.1.135]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 11 Oct 2011 11:33:28 -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 Received: from localhost.localdomain (d941e-10.watson.ibm.com [9.59.241.154]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p9BHX7m0029580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 11 Oct 2011 11:33:08 -0600 Received: from localhost.localdomain (d941e-10 [127.0.0.1]) by localhost.localdomain (8.14.4/8.14.3) with ESMTP id p9BHX7S1027825; Tue, 11 Oct 2011 13:33:07 -0400 Received: (from root@localhost) by localhost.localdomain (8.14.4/8.14.4/Submit) id p9BHX7rT027824; Tue, 11 Oct 2011 13:33:07 -0400 Message-Id: <20111011173307.151325846@linux.vnet.ibm.com> User-Agent: quilt/0.48-1 Date: Tue, 11 Oct 2011 13:32:23 -0400 From: Stefan Berger To: stefanb@linux.vnet.ibm.com, qemu-devel@nongnu.org References: <20111011173216.247822737@linux.vnet.ibm.com> Content-Disposition: inline; filename=qemu_parse_fd.diff x-cbid: 11101117-6148-0000-0000-0000002A5C69 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.153 Cc: mst@redhat.com, andreas.niederl@iaik.tugraz.at, serge@hallyn.com Subject: [Qemu-devel] [PATCH V12 7/8] Move parsing of filedescriptor into common function 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 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; +}