From: Gianni Tedesco Subject: Re: [PATCH]: xl: don't segfault parsing disk configs, support NULL physpath and ioemu: Date: Thu, 19 Aug 2010 15:58:02 +0100 Message-ID: <1282229882.3731.32.camel@qabil.uk.xensource.com> References: <1282228463.3731.27.camel@qabil.uk.xensource.com> <19565.17853.246902.357872@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <19565.17853.246902.357872@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: Kamala Narasimhan , Christoph Egger , Xen Devel , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Thu, 2010-08-19 at 15:54 +0100, Ian Jackson wrote: > Gianni Tedesco writes ("[Xen-devel] [PATCH]: xl: don't segfault parsing disk configs, support NULL physpath and ioemu:"): > > Switch to a state machine parser since it's easier to handle all these > > exotic cases without segfaulting. NULL physpaths are now allowed and a > > dodgy hack is introduced to skip over the "ioemu:" prefix for a > > virtpath. Also fixes a leak of buf2. > > I'm not convinced that it is clearer. It's certainly a lot longer: > 132 lines added for 50 removed. It's true that it's longer but the nature of these types of parsers it's a lot of very short lines :) I think it's clearer than a correct strtok() + handling all errors and variations would be. > Perhaps we should just import a regexp parser and use that ? Really, > we should have a regexp or some other kind of declarative statement of > the syntax. > > Possible regexp parsers include pcre and flex. flex has the advantage > that we're using it already so it's just another line in the > Makefile. It's your call, I know nothing of flex and its mysterious ways and my pcre skills are limited to basic text-editor-fu... I agree that flex probably makes the most sense. On the other hand whoever designed these formats seemed to want to make them difficult to parse. Since it's all python I find myself wondering why they didn't use a dictionary or a tuple. Gianni