]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
namespace: make ns_type_supported() a tiny bit shorter 7045/head
authorLennart Poettering <lennart@poettering.net>
Tue, 10 Oct 2017 07:50:23 +0000 (09:50 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 10 Oct 2017 07:52:08 +0000 (09:52 +0200)
namespace_type_to_string() already validates the type paramater, we can
use that, and shorten the function a bit.

src/core/namespace.c

index ac5fde16f41a67e2a3e7df8e9044d395a7e6202a..9624d8aa69d312d902a4b3f463077aa4441c680e 100644 (file)
@@ -1431,12 +1431,11 @@ fail:
 bool ns_type_supported(NamespaceType type) {
         const char *t, *ns_proc;
 
-        if (type <= _NAMESPACE_TYPE_INVALID || type >= _NAMESPACE_TYPE_MAX)
+        t = namespace_type_to_string(type);
+        if (!t) /* Don't know how to translate this? Then it's not supported */
                 return false;
 
-        t = namespace_type_to_string(type);
         ns_proc = strjoina("/proc/self/ns/", t);
-
         return access(ns_proc, F_OK) == 0;
 }