From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2Evt-0006zd-9j for qemu-devel@nongnu.org; Thu, 03 Nov 2016 06:07:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2Evq-0005k0-2e for qemu-devel@nongnu.org; Thu, 03 Nov 2016 06:07:41 -0400 Received: from mga05.intel.com ([192.55.52.43]:39973) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c2Evp-0005jq-T6 for qemu-devel@nongnu.org; Thu, 03 Nov 2016 06:07:38 -0400 References: <1478145090-11987-1-git-send-email-guangrong.xiao@linux.intel.com> <1478145090-11987-2-git-send-email-guangrong.xiao@linux.intel.com> <20161103100015.GB5154@stefanha-x1.localdomain> From: Xiao Guangrong Message-ID: <924ef0bb-b320-a05c-486d-d2c281fa34fe@linux.intel.com> Date: Thu, 3 Nov 2016 17:58:46 +0800 MIME-Version: 1.0 In-Reply-To: <20161103100015.GB5154@stefanha-x1.localdomain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 1/3] nvdimm acpi: introduce fit buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: pbonzini@redhat.com, imammedo@redhat.com, gleb@kernel.org, mtosatti@redhat.com, stefanha@redhat.com, mst@redhat.com, rth@twiddle.net, ehabkost@redhat.com, dan.j.williams@intel.com, kvm@vger.kernel.org, qemu-devel@nongnu.org On 11/03/2016 06:00 PM, Stefan Hajnoczi wrote: > On Thu, Nov 03, 2016 at 11:51:28AM +0800, Xiao Guangrong wrote: >> +static void nvdimm_init_fit_buffer(NvdimmFitBuffer *fit_buf) >> +{ >> + fit_buf->fit = g_array_new(false, true /* clear */, 1); >> +} >> + >> +static void nvdimm_build_fit_buffer(NvdimmFitBuffer *fit_buf) >> +{ >> + g_array_free(fit_buf->fit, true); >> + fit_buf->fit = nvdimm_build_device_structure(); > > In the previous revision I pointed out that it's messy to inline > g_array_new(false, true /* clear */, 1) in nvdimm_init_fit_buffer() when > the data structure is normally created by > nvdimm_build_device_structure(). You didn't respond. > Oh, sorry for that. > Is it possible to call nvdimm_build_device_structure() in > nvdimm_init_fit_buffer() so we don't need to duplicate the details of > how the GArray is created? > Actually, i tried your suggestion however i noticed it makes the code little confuse, as we construct the fit by calling nvdimm_build_device_structure() whose name shows the fit will be rebuild but do not set .dirty in the init path. g_array_new(false, true /* clear */, 1) is a more clear way to show this is just a empty array.