On Tue, Aug 14, 2012 at 10:29:26AM +0200, Kevin Wolf wrote: > Am 14.08.2012 06:38, schrieb Bharata B Rao: > > Kevin, Thanks for your review. I will address all of your comments > > in the next iteration, but have a few questions/comments on the others... > > > > On Mon, Aug 13, 2012 at 02:50:29PM +0200, Kevin Wolf wrote: > >>> +static int parse_server(GlusterURI *uri, char *server) > >>> +{ > >>> + int ret = -EINVAL; > >>> + char *token, *saveptr; > >>> + char *p, *q = server; > >>> + > >>> + p = strchr(server, '['); > >>> + if (p) { > >>> + /* [ipv6] */ > >>> + if (p != server) { > >>> + /* [ not in the beginning */ > >>> + goto out; > >>> + } > >>> + q++; > >>> + p = strrchr(p, ']'); > >>> + if (!p) { > >>> + /* No matching ] */ > >>> + goto out; > >>> + } > >>> + *p++ = '\0'; > >>> + uri->server = g_strdup(q); > >>> + > >>> + if (*p) { > >>> + if (*p != ':') { > >>> + /* [ipv6] followed by something other than : */ > >>> + goto out; > >>> + } > >>> + uri->port = strtoul(++p, NULL, 0); > >>> + if (uri->port < 0) { > >>> + goto out; > >>> + } > >> > > > In any case, let me see if I can get rid of this altogether and reuse > > qemu-sockets.c:inet_parse().
Using inet_parse() outside of qemu-sockets.c needs some work like making it non-static, defining QemuOptsList for inet opts and fixing some issues with inet_parse(like making it successfully parse 'hostname' also instead of just 'hostname:port'). I will give this a try and send a patch. Regards, Bharata.