]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: call cap_last_cap() only once in has_cap() 10349/head
authorLennart Poettering <lennart@poettering.net>
Wed, 10 Oct 2018 09:12:54 +0000 (11:12 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 10 Oct 2018 09:13:00 +0000 (11:13 +0200)
Also, use the same type everywhere for dealing with it.

src/libsystemd/sd-bus/bus-creds.c

index 722366a6fd3be94812659873167d27b0febf6edb..a6dda16876ce0bb7fbf7a222c0cc614fb15e0906 100644 (file)
@@ -650,16 +650,19 @@ _public_ int sd_bus_creds_get_description(sd_bus_creds *c, const char **ret) {
 }
 
 static int has_cap(sd_bus_creds *c, size_t offset, int capability) {
+        unsigned long lc;
         size_t sz;
 
         assert(c);
         assert(capability >= 0);
         assert(c->capability);
 
-        if ((unsigned) capability > cap_last_cap())
+        lc = cap_last_cap();
+
+        if ((unsigned long) capability > lc)
                 return 0;
 
-        sz = DIV_ROUND_UP(cap_last_cap(), 32U);
+        sz = DIV_ROUND_UP(lc, 32LU);
 
         return !!(c->capability[offset * sz + CAP_TO_INDEX((uint32_t) capability)] & CAP_TO_MASK_CORRECTED((uint32_t) capability));
 }