From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEnLE-0006Wj-Ee for qemu-devel@nongnu.org; Thu, 20 Sep 2012 16:27:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEnLD-0001ts-4k for qemu-devel@nongnu.org; Thu, 20 Sep 2012 16:27:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEnLC-0001th-Si for qemu-devel@nongnu.org; Thu, 20 Sep 2012 16:27:19 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8KKRIOu013385 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Sep 2012 16:27:18 -0400 From: Luiz Capitulino Date: Thu, 20 Sep 2012 17:28:01 -0300 Message-Id: <1348172883-26997-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1348172883-26997-1-git-send-email-lcapitulino@redhat.com> References: <1348172883-26997-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] pci-assign: use monitor_handle_fd_param List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: eblake@redhat.com, pbonzini@redhat.com From: Paolo Bonzini There is no need to open-code the choice between a file descriptor number or a named one. Just use monitor_handle_fd_param, which also takes care of printing the error message. Signed-off-by: Paolo Bonzini Signed-off-by: Luiz Capitulino --- hw/kvm/pci-assign.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index 05b93d9..7a0998c 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -579,15 +579,9 @@ static int get_real_device(AssignedDevice *pci_dev, uint16_t r_seg, snprintf(name, sizeof(name), "%sconfig", dir); if (pci_dev->configfd_name && *pci_dev->configfd_name) { - if (qemu_isdigit(pci_dev->configfd_name[0])) { - dev->config_fd = strtol(pci_dev->configfd_name, NULL, 0); - } else { - dev->config_fd = monitor_get_fd(cur_mon, pci_dev->configfd_name); - if (dev->config_fd < 0) { - error_report("%s: (%s) unkown", __func__, - pci_dev->configfd_name); - return 1; - } + dev->config_fd = monitor_handle_fd_param(cur_mon, pci_dev->configfd_name); + if (dev->config_fd < 0) { + return 1; } } else { dev->config_fd = open(name, O_RDWR); -- 1.7.12.315.g682ce8b