Re: [PATCH 1/4] Add APIs for formatting systemd slice/scope names

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

 



On 07/26/2013 09:48 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> 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 <berrange@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]