qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v7 5/5] block: Support GlusterFS as a QEMU block


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v7 5/5] block: Support GlusterFS as a QEMU block backend.
Date: Thu, 20 Sep 2012 10:20:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]