Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -3
+8 -3
tools/perf/util/namespaces.c
··· 177 177 return nsi; 178 178 } 179 179 180 + static const char *nsinfo__mntns_path(const struct nsinfo *nsi) 181 + { 182 + return RC_CHK_ACCESS(nsi)->mntns_path; 183 + } 184 + 180 185 struct nsinfo *nsinfo__copy(const struct nsinfo *nsi) 181 186 { 182 187 struct nsinfo *nnsi; ··· 198 193 RC_CHK_ACCESS(nnsi)->nstgid = nsinfo__nstgid(nsi); 199 194 RC_CHK_ACCESS(nnsi)->need_setns = nsinfo__need_setns(nsi); 200 195 RC_CHK_ACCESS(nnsi)->in_pidns = nsinfo__in_pidns(nsi); 201 - if (RC_CHK_ACCESS(nsi)->mntns_path) { 202 - RC_CHK_ACCESS(nnsi)->mntns_path = strdup(RC_CHK_ACCESS(nsi)->mntns_path); 196 + if (nsinfo__mntns_path(nsi)) { 197 + RC_CHK_ACCESS(nnsi)->mntns_path = strdup(nsinfo__mntns_path(nsi)); 203 198 if (!RC_CHK_ACCESS(nnsi)->mntns_path) { 204 199 nsinfo__put(nnsi); 205 200 return NULL; ··· 299 294 if (oldns < 0) 300 295 goto errout; 301 296 302 - newns = open(RC_CHK_ACCESS(nsi)->mntns_path, O_RDONLY); 297 + newns = open(nsinfo__mntns_path(nsi), O_RDONLY); 303 298 if (newns < 0) 304 299 goto errout; 305 300