On 07/26/2013 09:48 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berra...@redhat.com>
> 
> There are some interesting escaping rules to consider when dealing
> with systemd slice/scope names. Thus it is helpful to have APIs
> for formatting names
> 
> Signed-off-by: Daniel P. Berrange <berra...@redhat.com>
> ---
>  src/libvirt_private.syms |  2 ++
>  src/util/virsystemd.c    | 91 
> ++++++++++++++++++++++++++++++++++++++++++++++--
>  src/util/virsystemd.h    |  5 +++
>  tests/virsystemdtest.c   | 48 +++++++++++++++++++++++++
>  4 files changed, 144 insertions(+), 2 deletions(-)
> 

> +
> +#define VALID_CHARS                             \
> +        "0123456789"                            \
> +        "abcdefghijklmnopqrstuvwxyz"            \
> +        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"            \
> +        ":-_.\\"

If you would remove - and \\ from this list...

> +
> +    if (*name == '.') {
> +        ESCAPE(*name);
> +        name++;
> +    }
> +
> +    while (*name) {
> +        if (*name == '/')
> +            virBufferAddChar(buf, '-');
> +        else if (*name == '-' ||
> +                 *name == '\\' ||
> +                 !strchr(VALID_CHARS, *name))

...then this could be simplified to just !strchr().

> +
> +
> +char *virSystemdMakeScopeName(const char *name,

Is it worth using the style:

char *
virSystemdMakeScopeName(...

> +    TEST_SCOPE("demo", "/machine/eng-dept/testing!stuff", 
> "machine-eng\\x2ddept-testing\\x21stuff-lxc\\x2ddemo.scope");

Worth wrapping the long line.

ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to