From: Ian Jackson Subject: Re: [PATCH] libxl: new xlu_disk_parse function Date: Thu, 31 Mar 2011 18:33:08 +0100 Message-ID: <19860.47828.119869.764622@mariner.uk.xensource.com> References: <1300988989-18305-1-git-send-email-ian.jackson@eu.citrix.com> <1300988989-18305-2-git-send-email-ian.jackson@eu.citrix.com> <1301333477.1691.7.camel@qabil.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" , Gianni Tedesco List-Id: xen-devel@lists.xenproject.org Stefano Stabellini writes ("Re: [Xen-devel] [PATCH] libxl: new xlu_disk_parse function"): > On Mon, 28 Mar 2011, Gianni Tedesco wrote: > > Hmm, I'm not sure this is nicer than the code it's replacing, it's > > certainly a lot longer. I don't like the idea of it being full of things > > comparing for ",w" or ":cdrom" etc, rather than tokenising it fully and > > evaluating what the tokens are separately. > > I definitely agree. > Besides when doing refactoring the code produced should be either shorter or > at least easier to read but this code is neither of them. I agree that as a rule of thumb better code is shorter. Unfortunately string parsing in C is one of those exceptions. What I was trying to do was to separate out the actual syntax in a way that is reasonably tractable, and which is amenable to being edited later without introducing bugs. So while the current code is longer in this case I think it's clearer. A good deal of the added code is very simple and straightforward "set up this regexp engine and check the return value". It is a shame that the syntax is so abstruse. We can do better with the nic parameters which have a better syntax. Ian.