From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEc0D-0007rK-37 for qemu-devel@nongnu.org; Thu, 20 Sep 2012 04:20:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEbzx-00055j-TB for qemu-devel@nongnu.org; Thu, 20 Sep 2012 04:20:53 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:53211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEbzx-00055V-Lw for qemu-devel@nongnu.org; Thu, 20 Sep 2012 04:20:37 -0400 Received: by bkcjg9 with SMTP id jg9so724213bkc.4 for ; Thu, 20 Sep 2012 01:20:36 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <505AD1D1.70604@redhat.com> Date: Thu, 20 Sep 2012 10:20:33 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <20120917152149.GB6879@in.ibm.com> <20120917152620.GG6879@in.ibm.com> <50587ED6.9040504@redhat.com> <20120920064114.GD5873@in.ibm.com> <505ACB62.7020409@redhat.com> In-Reply-To: <505ACB62.7020409@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v7 5/5] block: Support GlusterFS as a QEMU block backend. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Anthony Liguori , Anand Avati , Vijay Bellur , Stefan Hajnoczi , Amar Tumballi , qemu-devel@nongnu.org, Markus Armbruster , Blue Swirl , Avi Kivity , bharata@linux.vnet.ibm.com Il 20/09/2012 09:53, Paolo Bonzini ha scritto: >>>> Would look a bit nicer with strstart() form cutils.c instead of strncmp(). >> > strstart() works with const char pointers, but I have char pointers here >> > which I need to modify. > You can pass a char* to a function that accepts const char*. In your > case, the last argument to strstart would be NULL. As you pointed out on IRC, you meant the last argument. I don't think it would be a problem to cast that from char ** to const char **. Perhaps it would be cleaner to make qemu_gluster_parseuri and parse_gluster_spec accept a const char *. You can replace strtok_r + g_strdup with strspn/strcspn followed by g_strndup. BTW, here the second strtok_r needs to stop at "&". > +static int parse_socket(GlusterURI *uri, char *socket) > +{ > + char *token, *saveptr; > + > + if (!socket) { > + return 0; > + } > + token = strtok_r(socket, "=", &saveptr); > + if (!token || strcmp(token, "socket")) { > + return -EINVAL; > + } > + token = strtok_r(NULL, "=", &saveptr); > + if (!token) { > + return -EINVAL; > + } And the same for the second strtok_r here too: > + /* socket */ > + token = strtok_r(NULL, "?", &saveptr); > + ret = parse_socket(uri, token); > + if (ret < 0) { > + goto out; > + } > + > + /* Flag error for extra options */ > + token = strtok_r(NULL, "?", &saveptr); > + if (token) { > + ret = -EINVAL; > + goto out; > + } > + Paolo