From: Ian Campbell Subject: Re: [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too Date: Mon, 16 Jan 2012 16:23:05 +0000 Message-ID: <1326730986.14689.19.camel@zakaz.uk.xensource.com> References: <0d3abdb6c01894e4e074.1326716121@cosworth.uk.xensource.com> <20244.19379.430191.296744@mariner.uk.xensource.com> <1326730504.14689.17.camel@zakaz.uk.xensource.com> <20244.19813.629009.581935@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20244.19813.629009.581935@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Mon, 2012-01-16 at 16:16 +0000, Ian Jackson wrote: > Ian Campbell writes ("Re: [Xen-devel] [PATCH 23 of 32 RFC] libxl: use libxl_*_init internally too"): > > I think the reason is that sometimes they might allocate memory. Many of > > them don't (I don't know about vfb in particular) and I don't know > > whether we prefer consistency in similar functions or avoiding pointless > > return values (I prefer the former so as to avoid needing to change the > > public API in the future when we find that we have introduced a way for > > a function to fail). > > Why might they need to allocate memory ? e.g. vif->model = strdup("rtl8139"). > > Possibly in the new world order (where init ~= memset and setdefaults > > does thework) this will no longer be the case, but then the same will > > become true of the setdefaults function. > > Yes. I think it's OK for setdefaults to be able to fail. > > Having infallible init functions is a real boon because it makes the > caller's memory management much easier, because they can always safely > dispose. I think my series has made more *_init functions have no possibility of failure but I don't think it is all of them. Ian.