From ced59f0bd65ff8e3352615fe3b00d212514eced7 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 13 Nov 2025 14:47:24 -0500 Subject: [PATCH] common: simplify fragment printing Fixes: https://tracker.ceph.com/issues/73792 Signed-off-by: Patrick Donnelly (cherry picked from commit a8bb5a891eef8aae11e7748f71eac666732f3cff) Resolves: rhbz#2414841 --- src/common/frag.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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) { -- 2.47.3