From: Patrick Donnelly Date: Thu, 13 Nov 2025 19:47:24 +0000 (-0500) Subject: common: simplify fragment printing X-Git-Tag: v20.2.1~8^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=191aa45e8077cad5daf355725bfbfcf755a02e63;p=ceph.git common: simplify fragment printing There's better tooling for this now and we can avoid magic numbers. Fixes: https://tracker.ceph.com/issues/73792 Signed-off-by: Patrick Donnelly (cherry picked from commit 647de21c85f14d67e7941428c3af2ebeef39ad4f) --- diff --git a/src/common/frag.cc b/src/common/frag.cc index 13a8e154559..452f30ff5dc 100644 --- a/src/common/frag.cc +++ b/src/common/frag.cc @@ -17,6 +17,8 @@ #include "common/debug.h" #include "common/Formatter.h" +#include + #include #include @@ -52,13 +54,12 @@ void frag_t::generate_test_instances(std::list& ls) { std::ostream& operator<<(std::ostream& out, const frag_t& hb) { //out << std::hex << hb.value() << std::dec << "/" << hb.bits() << '='; - unsigned num = hb.bits(); - if (num) { - unsigned val = hb.value(); - for (unsigned bit = 23; num; num--, bit--) - out << ((val & (1< 0) { + auto v = hb.value() >> hb.mask_shift(); + return out << fmt::format("{0:0{1}b}*", v, b); + } else { + return out << '*'; } - return out << '*'; } bool fragtree_t::force_to_leaf(CephContext *cct, frag_t x) {