diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-18 03:11:58 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-18 03:22:24 +0200 |
commit | 2d1acd3f10baed49329c1b201cafb060aeb377e0 (patch) | |
tree | 8e2a827a2b127462ec38e3672b9a9f16b85b2fa0 /tools/perf/util | |
parent | perf namespaces: Introduce nsinfo__refcnt() accessor to avoid accessing ->ref... (diff) | |
download | linux-2d1acd3f10baed49329c1b201cafb060aeb377e0.tar.xz linux-2d1acd3f10baed49329c1b201cafb060aeb377e0.zip |
perf namespaces: Introduce nsinfo__mntns_path() accessor to avoid accessing ->mntns_path directly
To reduce the use of RC_CHK_ACCESS(nsi).
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/namespaces.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c index 2f9fb1e2769c..cb185c5659d6 100644 --- a/tools/perf/util/namespaces.c +++ b/tools/perf/util/namespaces.c @@ -177,6 +177,11 @@ struct nsinfo *nsinfo__new(pid_t pid) return nsi; } +static const char *nsinfo__mntns_path(const struct nsinfo *nsi) +{ + return RC_CHK_ACCESS(nsi)->mntns_path; +} + struct nsinfo *nsinfo__copy(const struct nsinfo *nsi) { struct nsinfo *nnsi; @@ -193,8 +198,8 @@ struct nsinfo *nsinfo__copy(const struct nsinfo *nsi) RC_CHK_ACCESS(nnsi)->nstgid = nsinfo__nstgid(nsi); RC_CHK_ACCESS(nnsi)->need_setns = nsinfo__need_setns(nsi); RC_CHK_ACCESS(nnsi)->in_pidns = nsinfo__in_pidns(nsi); - if (RC_CHK_ACCESS(nsi)->mntns_path) { - RC_CHK_ACCESS(nnsi)->mntns_path = strdup(RC_CHK_ACCESS(nsi)->mntns_path); + if (nsinfo__mntns_path(nsi)) { + RC_CHK_ACCESS(nnsi)->mntns_path = strdup(nsinfo__mntns_path(nsi)); if (!RC_CHK_ACCESS(nnsi)->mntns_path) { nsinfo__put(nnsi); return NULL; @@ -294,7 +299,7 @@ void nsinfo__mountns_enter(struct nsinfo *nsi, if (oldns < 0) goto errout; - newns = open(RC_CHK_ACCESS(nsi)->mntns_path, O_RDONLY); + newns = open(nsinfo__mntns_path(nsi), O_RDONLY); if (newns < 0) goto errout; |