From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WfmnO-0001xI-Ms for qemu-devel@nongnu.org; Thu, 01 May 2014 04:56:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WfmnI-00066A-Hd for qemu-devel@nongnu.org; Thu, 01 May 2014 04:56:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WfmnI-00065G-9e for qemu-devel@nongnu.org; Thu, 01 May 2014 04:56:40 -0400 Message-ID: <53620C41.3040506@redhat.com> Date: Thu, 01 May 2014 09:56:33 +0100 From: Matthew Booth MIME-Version: 1.0 References: <1398867658-2069-1-git-send-email-mbooth@redhat.com> <1398867658-2069-2-git-send-email-mbooth@redhat.com> <20140430151638.GE4380@noname.redhat.com> In-Reply-To: <20140430151638.GE4380@noname.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/3] curl: Fix parsing of readahead option from filename List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com On 30/04/14 16:16, Kevin Wolf wrote: > Am 30.04.2014 um 16:20 hat Matthew Booth geschrieben: >> curl_parse_filename wasn't removing the option string from the url, >> resulting in a 404. >> >> This change is a essentially a rewrite of that function as I also need >> to extend it to handle more options. The rewrite is also much easier >> to read. >> >> Signed-off-by: Matthew Booth >> --- >> block/curl.c | 81 ++++++++++++++++++++++++++++++++++++++---------------------- >> 1 file changed, 52 insertions(+), 29 deletions(-) >> >> diff --git a/block/curl.c b/block/curl.c >> index d2f1084..4de6856 100644 >> --- a/block/curl.c >> +++ b/block/curl.c >> @@ -46,12 +46,15 @@ >> #define CURL_NUM_STATES 8 >> #define CURL_NUM_ACB 8 >> #define SECTOR_SIZE 512 >> -#define READ_AHEAD_SIZE (256 * 1024) >> +#define READ_AHEAD_DEFAULT (256 * 1024) >> >> #define FIND_RET_NONE 0 >> #define FIND_RET_OK 1 >> #define FIND_RET_WAIT 2 >> >> +#define CURL_BLOCK_OPT_URL "url" >> +#define CURL_BLOCK_OPT_READAHEAD "readahead" >> + >> struct BDRVCURLState; >> >> typedef struct CURLAIOCB { >> @@ -396,41 +399,60 @@ static void curl_clean_state(CURLState *s) >> static void curl_parse_filename(const char *filename, QDict *options, >> Error **errp) >> { >> - >> - #define RA_OPTSTR ":readahead=" >> char *file; >> - char *ra; >> - const char *ra_val; >> - int parse_state = 0; >> + char *end; >> >> file = g_strdup(filename); >> + end = file + strlen(file) - 1; >> + >> + /* Don't fail if we've been passed an empty string. >> + * Only examine strings with a trailing ':' >> + */ >> + if (end >= file && *end == ':') { >> + /* We exit this loop when we don't find a recognised option immediately >> + * preceding the trailing ':' of the form ':