@@ -224,29 +224,23 @@ namespace os::mem {
224224 template <typename Fl>
225225 inline std::string Mapping<Fl>::to_string() const {
226226 using namespace util ::literals;
227- char buffer[1024 ];
228- int len = snprintf (buffer, sizeof (buffer),
229- " %p -> %p, size %s, flags %#x" ,
230- (void *) lin,
231- (void *) phys,
232- util::Byte_r (size).to_string ().c_str (),
233- (int ) flags);
234-
235- const bool isseq = __builtin_popcount (page_sizes) == 1 ;
227+
228+ std::string s = std::format ( " lin {} -> phys {}, size {}, flags {:#x}" ,
229+ lin, phys, util::Byte_r (size).to_string (), static_cast <unsigned >(flags));
230+
231+ const bool isseq = std::popcount (page_sizes) == 1 ;
236232 if (isseq) {
237- len += snprintf (buffer + len, sizeof (buffer) - len,
238- " (%lu pages á %s)" ,
239- size / page_sizes,
240- util::Byte_r (page_sizes).to_string ().c_str ());
233+ const auto pages = size / page_sizes;
234+ s += std::format (" ({} pages á {})" , pages, util::Byte_r (page_sizes).to_string ());
241235 } else {
242- len += snprintf (buffer + len, sizeof (buffer) - len,
243- " (page sizes: %s)" , page_sizes_str (page_sizes).c_str ());
236+ s += std::format (" (page sizes: {})" , page_sizes_str (page_sizes));
244237 }
245- return std::string (buffer, len) ;
238+ return s ;
246239 }
247240
248241 inline std::string page_sizes_str (size_t bits) {
249242 using namespace util ::literals;
243+
250244 if (bits == 0 ) return " None" ;
251245
252246 std::string out;
0 commit comments