diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-05-10 18:47:33 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-05-10 18:47:33 +0200 |
commit | 945403e6edbe6bf98015aabb38b281aa89334d0a (patch) | |
tree | 83f64d3cb247b4e5070ca673b4fdf30e7a275843 /src/cgtop | |
parent | core: merge duplicated functions (diff) | |
download | systemd-945403e6edbe6bf98015aabb38b281aa89334d0a.tar.xz systemd-945403e6edbe6bf98015aabb38b281aa89334d0a.zip |
path-util: introduce empty_to_root() and use it many places
Diffstat (limited to 'src/cgtop')
-rw-r--r-- | src/cgtop/cgtop.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index de7ecf54cd..401c08600a 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -529,10 +529,6 @@ static int refresh(const char *root, Hashmap *a, Hashmap *b, unsigned iteration) return 0; } -static const char *empty_to_slash(const char *p) { - return isempty(p) ? "/" : p; -} - static int group_compare(const void*a, const void *b) { const Group *x = *(Group**)a, *y = *(Group**)b; @@ -542,9 +538,9 @@ static int group_compare(const void*a, const void *b) { * recursive summing is off, since that is actually * not accumulative for all children. */ - if (path_startswith(empty_to_slash(y->path), empty_to_slash(x->path))) + if (path_startswith(empty_to_root(y->path), empty_to_root(x->path))) return -1; - if (path_startswith(empty_to_slash(x->path), empty_to_slash(y->path))) + if (path_startswith(empty_to_root(x->path), empty_to_root(y->path))) return 1; } @@ -693,7 +689,7 @@ static void display(Hashmap *a) { g = array[j]; - path = empty_to_slash(g->path); + path = empty_to_root(g->path); ellipsized = ellipsize(path, path_columns, 33); printf("%-*s", path_columns, ellipsized ?: path); |