]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
capability: add a way to get a uint64_t with all caps set
authorLennart Poettering <lennart@poettering.net>
Wed, 6 Mar 2019 10:37:04 +0000 (11:37 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 15 Mar 2019 14:33:09 +0000 (15:33 +0100)
src/basic/capability-util.h

index 02c7d5c3e2e2d815ffe096cfb0a854a80e27ec31..e69b2fbb957854da3ec0eb52ca977729155e4e3d 100644 (file)
@@ -33,10 +33,12 @@ static inline void cap_free_charpp(char **p) {
 }
 #define _cleanup_cap_free_charp_ _cleanup_(cap_free_charpp)
 
+static inline uint64_t all_capabilities(void) {
+        return UINT64_MAX >> (63 - cap_last_cap());
+}
+
 static inline bool cap_test_all(uint64_t caps) {
-        uint64_t m;
-        m = (UINT64_C(1) << (cap_last_cap() + 1)) - 1;
-        return FLAGS_SET(caps, m);
+        return FLAGS_SET(caps, all_capabilities());
 }
 
 bool ambient_capabilities_supported(void);