]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
cg_build_path adds needless "/" character
authorIvana Hutarova Varekova <varekova@redhat.com>
Fri, 22 Jun 2012 13:38:34 +0000 (15:38 +0200)
committerIvana Hutarova Varekova <varekova@redhat.com>
Fri, 22 Jun 2012 13:38:34 +0000 (15:38 +0200)
commit32a8597ce577e34d0dd8cda8d6f8fbaeebcb9987
tree3d43d45a94bfd1c3a4fbe02f44846204f7db37fd
parent0ac4325ee2c487cb76c55fb4773bb0cdb40cd7c2
cg_build_path adds needless "/" character

    cg_build_path adds needless "/" character in cases when the input path
    ends/starts with character "/" itself. This character is added now only
in cases it is wanted and it was not set.

    Changelog
    - incorporate Jan's feedback - fix typo in patch description, use snprintf instead of sprintf
    - deal with the situation if directory name is empty as well
    - move the path concatenation functionality to a separate function

    Example:
    Old version:
    cg_build_path("", path, memory);
    returns /sys/fs/cgroup/memory//
    cg_build_path("/3", path, memory);
    returns /sys/fs/cgroup/memory//3/
    cg_build_path("3/", path, memory);
    returns /sys/fs/cgroup/memory/3//

    New version:
    cg_build_path("", path, memory);
    returns /sys/fs/cgroup/memory/
    cg_build_path("/3", path, memory);
    returns /sys/fs/cgroup/memory/3/
    cg_build_path("3/", path, memory);
    returns /sys/fs/cgroup/memory/3/

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
src/api.c