Skip to content

Commit 0fa5b83

Browse files
committed
namespace: make ns_type_supported() a tiny bit shorter
namespace_type_to_string() already validates the type paramater, we can use that, and shorten the function a bit.
1 parent bb0ff3f commit 0fa5b83

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/core/namespace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,12 +1431,11 @@ int setup_netns(int netns_storage_socket[2]) {
14311431
bool ns_type_supported(NamespaceType type) {
14321432
const char *t, *ns_proc;
14331433

1434-
if (type <= _NAMESPACE_TYPE_INVALID || type >= _NAMESPACE_TYPE_MAX)
1434+
t = namespace_type_to_string(type);
1435+
if (!t) /* Don't know how to translate this? Then it's not supported */
14351436
return false;
14361437

1437-
t = namespace_type_to_string(type);
14381438
ns_proc = strjoina("/proc/self/ns/", t);
1439-
14401439
return access(ns_proc, F_OK) == 0;
14411440
}
14421441

0 commit comments

Comments
 (0)