Received: from eggs.gnu.org ([208.118.235.92]:47989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBPg6-0004xB-Fh for qemu-devel@nongnu.org; Tue, 11 Sep 2012 08:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBPg0-0005aH-Nu for qemu-devel@nongnu.org; Tue, 11 Sep 2012 08:34:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8849) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBPg0-0005aC-Fe for qemu-devel@nongnu.org; Tue, 11 Sep 2012 08:34:48 -0400 From: Markus Armbruster References: <20120911082824.GA24816@in.ibm.com> Date: Tue, 11 Sep 2012 14:34:09 +0200 In-Reply-To: <20120911082824.GA24816@in.ibm.com> (Bharata B. Rao's message of "Tue, 11 Sep 2012 13:58:24 +0530") Message-ID: <87k3w0pwla.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v1] Make inet_parse() non-static List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: bharata@linux.vnet.ibm.com Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org, Gerd Hoffmann Bharata B Rao writes: > From: Bharata B Rao > > Make inet_parse() non static. > > - Make inet_parse() non-static so that other subsystems like gluster > can use it to parse inet addresses. As a pre-requisite, define and > globalize the qemu_inet_opts. Please repost this as part of a series that needs non-static inet_parse(). I'm worried parameter "block" will cause trouble, but I can't see that without the users. > - Extend inet_parse() to parse just 'address' also in addition to > 'address:port'. Separate patch, please. > Signed-off-by: Bharata B Rao > --- > Ideally I needn't use sscanf twice once for parsing host:port (checking > return value of 2) and if that fails for parsing host w/o port (checking > return value of 1). I could just check if sscanf returned 2 or 1 and decide > if addr:port or just addr was provided, but in the latter case the > pointer to the bytes consumed (&pos) doesn't get updated. You can use two of them, like this: a_end = b_end = -1; sscanf(str, "%d%n:%d%n", &a, &a_end, &b, &b_end); if (b_end >= 0) ... [...]