]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/util: rename u64log2 to log2u64
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 26 Nov 2021 10:40:17 +0000 (11:40 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 26 Nov 2021 14:29:06 +0000 (15:29 +0100)
u64log2 was strangely named. We even have log2i and log2u right below
in that file.

src/basic/capability-util.c
src/basic/util.h
src/journal/journald-rate-limit.c
src/libsystemd/sd-event/sd-event.c
src/test/test-util.c

index b31a9cb2113c0ab9d2ba5eeccadabfda1728e164..fa74b5b9c631ef4a500c0a82b3f7d92b072b59e9 100644 (file)
@@ -336,7 +336,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
 
         /* Now upgrade the permitted caps we still kept to effective caps */
         if (keep_capabilities != 0) {
-                cap_value_t bits[u64log2(keep_capabilities) + 1];
+                cap_value_t bits[log2u64(keep_capabilities) + 1];
                 _cleanup_cap_free_ cap_t d = NULL;
                 unsigned i, j = 0;
 
index b6c51c036eb89c85e6aaffff541635beb0dba2c7..20bda9bbf3e46646f863054103c39567766e05da 100644 (file)
@@ -22,7 +22,7 @@ void in_initrd_force(bool value);
 
 int on_ac_power(void);
 
-static inline unsigned u64log2(uint64_t n) {
+static inline unsigned log2u64(uint64_t n) {
 #if __SIZEOF_LONG_LONG__ == 8
         return (n > 1) ? (unsigned) __builtin_clzll(n) ^ 63U : 0;
 #else
index f464b6e0d828f4c630a0796df1d13f839cddfc59..8accd7c7f59730e863ac49bc760914c82f7193ca 100644 (file)
@@ -162,7 +162,7 @@ static unsigned burst_modulate(unsigned burst, uint64_t available) {
         /* Modulates the burst rate a bit with the amount of available
          * disk space */
 
-        k = u64log2(available);
+        k = log2u64(available);
 
         /* 1MB */
         if (k <= 20)
index 8d21627b3f24cb49e489cd1d8a3520ea684b1599..3c916f246663bfae6a3010eb134592c76c9c4aac 100644 (file)
@@ -4218,7 +4218,7 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
 
                 this_run = now(CLOCK_MONOTONIC);
 
-                l = u64log2(this_run - e->last_run_usec);
+                l = log2u64(this_run - e->last_run_usec);
                 assert(l < ELEMENTSOF(e->delays));
                 e->delays[l]++;
 
index 413469a26f93797e447027d1445a209ce8f23f37..8e8ad05205f082994ce39dd176bbc70638d08e6b 100644 (file)
 #include "tests.h"
 #include "util.h"
 
-TEST(u64log2) {
-        assert_se(u64log2(0) == 0);
-        assert_se(u64log2(8) == 3);
-        assert_se(u64log2(9) == 3);
-        assert_se(u64log2(15) == 3);
-        assert_se(u64log2(16) == 4);
-        assert_se(u64log2(1024*1024) == 20);
-        assert_se(u64log2(1024*1024+5) == 20);
+TEST(log2u64) {
+        assert_se(log2u64(0) == 0);
+        assert_se(log2u64(8) == 3);
+        assert_se(log2u64(9) == 3);
+        assert_se(log2u64(15) == 3);
+        assert_se(log2u64(16) == 4);
+        assert_se(log2u64(1024*1024) == 20);
+        assert_se(log2u64(1024*1024+5) == 20);
 }
 
 TEST(protect_errno) {