All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] make path_has_protocol() to return pointer instead of bool
Date: Fri, 21 Jan 2011 10:29:22 +0100	[thread overview]
Message-ID: <4D3951F2.9040901@redhat.com> (raw)
In-Reply-To: <1294829822-27938-2-git-send-email-mjt@msgid.tls.msk.ru>

Am 12.01.2011 11:57, schrieb Michael Tokarev:
> Currently protocol: parsing in filenames is ad-hoc and scattered all around
> block.c.  This is a first step to prepare for common parsing.
> 
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  block.c |   18 +++++++++++++++---
>  1 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/block.c b/block.c
> index ff2795b..e5a6f60 100644
> --- a/block.c
> +++ b/block.c
> @@ -90,9 +90,11 @@ int is_windows_drive(const char *filename)
>  }
>  #endif
>  
> -/* check if the path starts with "<protocol>:" */
> -static int path_has_protocol(const char *path)
> +/* check if the path starts with "<protocol>:"
> + * Return pointer to the leading colon or NULL */
> +static char *path_has_protocol(const char *path)
>  {
> +    const char *p;
>  #ifdef _WIN32
>      if (is_windows_drive(path) ||
>          is_windows_drive_prefix(path)) {
> @@ -100,7 +102,17 @@ static int path_has_protocol(const char *path)
>      }
>  #endif
>  
> -    return strchr(path, ':') != NULL;
> +    p = path;
> +    /* we allow [a-z_] for now */
> +    while((*p >= 'a' && *p <= 'z') || *p == '_') {

Maybe qemu_isalnum(*p)  || *p == '_' instead? We probably won't need
uppercase letters, but digits are well possible.

We'll have a hard time adding any characters here later as this will
break previously working image filenames.

> +        ++p;
> +    }
> +
> +#define MAX_PROTO_LEN 31
> +    /* recognize non-empty string of max MAX_PROTO chars as protocol */
> +    return
> +        *p == ':' && p > path && (p - path) <= MAX_PROTO_LEN ?
> +            (char*)p : NULL;

What's the point of MAX_PROTO_LEN? It just seems to make the handling
even less consistent than it already is.

Kevin

  reply	other threads:[~2011-01-21  9:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1294829822-27938-1-git-send-email-mjt@tls.msk.ru>
2011-01-12 10:57 ` [Qemu-devel] [PATCH 1/3] make path_has_protocol() to return pointer instead of bool Michael Tokarev
2011-01-21  9:29   ` Kevin Wolf [this message]
2011-01-12 10:57 ` [Qemu-devel] [PATCH 2/3] use new path_has_protocol() in bdrv_find_protocol() Michael Tokarev
2011-01-12 10:57 ` [Qemu-devel] [PATCH 3/3] make path_combine() especially for filenames, not URLs Michael Tokarev
2011-01-21 10:07   ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D3951F2.9040901@redhat.com \
    --to=kwolf@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.