From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH v6 07/33] util: introduce qemu_file_get_page_size() Date: Sat, 31 Oct 2015 16:25:52 +0800 Message-ID: <56347B10.3040305@linux.intel.com> References: <1446184587-142784-1-git-send-email-guangrong.xiao@linux.intel.com> <1446184587-142784-8-git-send-email-guangrong.xiao@linux.intel.com> <20151030155454.GS4180@thinpad.lan.raisama.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: pbonzini@redhat.com, imammedo@redhat.com, gleb@kernel.org, mtosatti@redhat.com, stefanha@redhat.com, mst@redhat.com, rth@twiddle.net, dan.j.williams@intel.com, kvm@vger.kernel.org, qemu-devel@nongnu.org To: Eduardo Habkost Return-path: Received: from mga14.intel.com ([192.55.52.115]:57874 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751576AbbJaIcc (ORCPT ); Sat, 31 Oct 2015 04:32:32 -0400 In-Reply-To: <20151030155454.GS4180@thinpad.lan.raisama.net> Sender: kvm-owner@vger.kernel.org List-ID: On 10/30/2015 11:54 PM, Eduardo Habkost wrote: > On Fri, Oct 30, 2015 at 01:56:01PM +0800, Xiao Guangrong wrote: >> There are three places use the some logic to get the page size on >> the file path or file fd >> >> This patch introduces qemu_file_get_page_size() to unify the code >> >> Signed-off-by: Xiao Guangrong > [...] >> diff --git a/util/oslib-posix.c b/util/oslib-posix.c >> index 914cef5..ad94c5a 100644 >> --- a/util/oslib-posix.c >> +++ b/util/oslib-posix.c >> @@ -360,6 +360,22 @@ static size_t fd_getpagesize(int fd) >> return getpagesize(); >> } >> >> +size_t qemu_file_get_page_size(const char *path) >> +{ >> + size_t size = 0; >> + int fd = qemu_open(path, O_RDONLY); >> + >> + if (fd < 0) { >> + fprintf(stderr, "Could not open %s.\n", path); >> + goto exit; > > Have you considered using a Error** argument here? No. But it looks it a good way to detect error by check if Error is NULL. Will use it. :)