diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-09 18:35:52 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-02-09 18:35:52 +0100 |
commit | b734a4ff1433e3804a0cbf0801fb81a059f97a79 (patch) | |
tree | ac50ed1f57522ee7a0b9c14bb892fd3878c5b1c1 /src/cgtop | |
parent | cgtop: hook up new /proc based emulation code for root cgroup memory/cpu stats (diff) | |
download | systemd-b734a4ff1433e3804a0cbf0801fb81a059f97a79.tar.xz systemd-b734a4ff1433e3804a0cbf0801fb81a059f97a79.zip |
cgroup-util: rework cg_get_keyed_attribute() a bit
Let's make sure we don't clobber the return parameter on failure, to
follow our coding style. Also, break the loop early if we have all
attributes we need.
This also changes the keys parameter to a simple char**, so that we can
use STRV_MAKE() for passing the list of attributes to read.
This also makes it possible to distuingish the case when the whole
attribute file doesn't exist from one key in it missing. In the former
case we return -ENOENT, in the latter we now return -ENXIO.
Diffstat (limited to 'src/cgtop')
-rw-r--r-- | src/cgtop/cgtop.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index ccd5fef0af..d7708dab2d 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -257,14 +257,13 @@ static int process( if (r < 0) return r; } else if (all_unified) { - const char *keys[] = { "usage_usec", NULL }; _cleanup_free_ char *val = NULL; if (!streq(controller, "cpu")) return 0; - r = cg_get_keyed_attribute("cpu", path, "cpu.stat", keys, &val); - if (r == -ENOENT) + r = cg_get_keyed_attribute("cpu", path, "cpu.stat", STRV_MAKE("usage_usec"), &val); + if (IN_SET(r, -ENOENT, -ENXIO)) return 0; if (r < 0) return r; |