diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-12-27 16:50:02 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-01-17 22:14:27 -0500 |
commit | 4d5bd50ab26f6233206c08364430270876c37b63 (patch) | |
tree | fbff2753f41c134c8fff1c104df53ce0a7d4d568 | |
parent | 469830d1426a91e0897c321fdc8ee428f0a750c1 (diff) |
seccomp: minor simplifications for is_seccomp_available()
-rw-r--r-- | src/shared/seccomp-util.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c index 497426f605..2c73cb8fa4 100644 --- a/src/shared/seccomp-util.c +++ b/src/shared/seccomp-util.c @@ -204,21 +204,22 @@ finish: } static bool is_basic_seccomp_available(void) { - int r; - r = prctl(PR_GET_SECCOMP, 0, 0, 0, 0); - return r >= 0; + return prctl(PR_GET_SECCOMP, 0, 0, 0, 0) >= 0; } static bool is_seccomp_filter_available(void) { - int r; - r = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0); - return r < 0 && errno == EFAULT; + return prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0) < 0 && + errno == EFAULT; } bool is_seccomp_available(void) { static int cached_enabled = -1; + if (cached_enabled < 0) - cached_enabled = is_basic_seccomp_available() && is_seccomp_filter_available(); + cached_enabled = + is_basic_seccomp_available() && + is_seccomp_filter_available(); + return cached_enabled; } |