diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2012-12-27 23:27:06 +0100 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2012-12-27 23:27:06 +0100 |
commit | bdd4de160c6b1252396db4b6531aa8c71e5b0698 (patch) | |
tree | 2d3e6071ae217754eabc07ce279fd5d155479d89 /src | |
parent | 8e92264b4ec3e67440da89ff6602320758840ffd (diff) |
cgroup: factorize path
Spare few bytes and make typos less likely.
Diffstat (limited to 'src')
-rw-r--r-- | src/libudev/cgroup-util.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libudev/cgroup-util.c b/src/libudev/cgroup-util.c index b0d378de5a..19f9889c8a 100644 --- a/src/libudev/cgroup-util.c +++ b/src/libudev/cgroup-util.c @@ -37,6 +37,8 @@ #include "path-util.h" #include "strv.h" +static const char cgroup_path[] = "/sys/fs/cgroup/"; + int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) { char *fs; int r; @@ -522,13 +524,13 @@ static int join_path(const char *controller, const char *path, const char *suffi if (controller) { if (path && suffix) - t = strjoin("/sys/fs/cgroup/", controller, "/", path, "/", suffix, NULL); + t = strjoin(cgroup_path, controller, "/", path, "/", suffix, NULL); else if (path) - t = strjoin("/sys/fs/cgroup/", controller, "/", path, NULL); + t = strjoin(cgroup_path, controller, "/", path, NULL); else if (suffix) - t = strjoin("/sys/fs/cgroup/", controller, "/", suffix, NULL); + t = strjoin(cgroup_path, controller, "/", suffix, NULL); else - t = strjoin("/sys/fs/cgroup/", controller, NULL); + t = strjoin(cgroup_path, controller, NULL); } else { if (path && suffix) t = strjoin(path, "/", suffix, NULL); @@ -572,8 +574,8 @@ static int check(const char *p) { assert(p); /* Check if this controller actually really exists */ - cc = alloca(sizeof("/sys/fs/cgroup/") + strlen(p)); - strcpy(stpcpy(cc, "/sys/fs/cgroup/"), p); + cc = alloca(sizeof(cgroup_path) + strlen(p)); + strcpy(stpcpy(cc, cgroup_path), p); if (access(cc, F_OK) < 0) return -errno; |