]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/intarith: s/8/CHAR_BIT/ 47761/head
authorKefu Chai <tchaikov@gmail.com>
Tue, 23 Aug 2022 15:38:39 +0000 (23:38 +0800)
committerKefu Chai <tchaikov@gmail.com>
Wed, 24 Aug 2022 09:49:41 +0000 (17:49 +0800)
less magic numbers

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/include/intarith.h

index 86002c312ba6750305f051187dd73516310ae59a..68b0345a457e2cb3a6d2d237ea9086b8659b4620 100644 (file)
@@ -16,6 +16,7 @@
 #define CEPH_INTARITH_H
 
 #include <bit>
+#include <climits>
 #include <concepts>
 #include <type_traits>
 
@@ -86,7 +87,7 @@ constexpr inline T p2roundup(T x, T align) {
 // count bits (set + any 0's that follow)
 template<std::integral T>
 unsigned cbits(T v) {
-  return (sizeof(v) * 8) - std::countl_zero(std::make_unsigned_t<T>(v));
+  return (sizeof(v) * CHAR_BIT) - std::countl_zero(std::make_unsigned_t<T>(v));
 }
 
 #endif