From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] tools/libxl: Correct use of phyinfo_{init, dispose}() Date: Wed, 5 Aug 2015 09:52:15 +0100 Message-ID: <55C1CEBF.5080707@citrix.com> References: <1438714718-23711-1-git-send-email-andrew.cooper3@citrix.com> <1438764034.9747.16.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1438764034.9747.16.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell , Xen-devel Cc: Wei Liu , Ian Jackson List-Id: xen-devel@lists.xenproject.org On 05/08/15 09:40, Ian Campbell wrote: > On Tue, 2015-08-04 at 19:58 +0100, Andrew Cooper wrote: >> Signed-off-by: Andrew Cooper >> --- >> CC: Ian Campbell >> CC: Ian Jackson >> CC: Wei Liu >> >> For my cpuid work which I have just started, I added an array to physinfo. >> Coverity then frowned at me when it spotted all the memory leaks. >> >> Technically speaking, 4.6 isn't broken due to not having an allocation to free >> in _dispose(), but this patch might still be worth taking in 4.6. > We've tended to be rather lax about this for internal code when there is no > actual work in the init/dispose functions in the current code base, so > while this improvement is the sort of thing we should/would routinely > except during development window I personally don't think it is worth a > freeze exception. Ok. > > @@ -4653,6 +4654,8 @@ static int libxl__fill_dom0_memory_info(libxl__gc >> *gc, uint32_t *target_memkb, >> if (rc < 0) >> goto out; >> >> + libxl_physinfo_dispose(&physinfo); >> + libxl_physinfo_init(&physinfo); > This pattern is starting to crop up a lot in loops of this type. I wonder > if I should make the idl generate a libxl_FOO_reinit() which just == > dispose+init? Probably a good idea. I believe I introduced the first use of that style, finding nothing better as an alternative. ~Andrew