]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common,include,msg: fmt 11 fixes
authorMatan Breizman <mbreizma@redhat.com>
Thu, 1 Aug 2024 12:54:16 +0000 (12:54 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 14 Aug 2024 09:56:24 +0000 (09:56 +0000)
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/common/LogEntry.h
src/common/fmt_common.h
src/include/utime_fmt.h
src/msg/Message.h
src/msg/async/frames_v2.cc
src/msg/msg_fmt.h

index 79e6742707b1ae46fff7a8fed2c4c70fe40d4e30..f79b76debaf0a793782956aa36a36400f4cd811e 100644 (file)
@@ -18,6 +18,7 @@
 #include <fmt/format.h>
 
 #include "include/utime.h"
+#include "include/utime_fmt.h"
 #include "msg/msg_fmt.h"
 #include "msg/msg_types.h"
 #include "common/entity_name.h"
@@ -217,14 +218,14 @@ template <> struct fmt::formatter<clog_type> : fmt::ostream_formatter {};
 
 template <> struct fmt::formatter<EntityName> : fmt::formatter<std::string_view> {
   template <typename FormatContext>
-  auto format(const EntityName& e, FormatContext& ctx) {
+  auto format(const EntityName& e, FormatContext& ctx) const {
     return formatter<std::string_view>::format(e.to_str(), ctx);
   }
 };
 
 template <> struct fmt::formatter<LogEntry> : fmt::formatter<std::string_view> {
   template <typename FormatContext>
-  auto format(const LogEntry& e, FormatContext& ctx) {
+  auto format(const LogEntry& e, FormatContext& ctx) const {
     return fmt::format_to(ctx.out(), "{} {} ({}) {} : {} [{}] {}",
                           e.stamp, e.name, e.rank, e.seq, e.channel,
                           LogEntry::level_to_str(e.prio), e.msg);
index 53ce8a10ddb78445bfa8e64316db123116bb9173..474f6fbc3247716f4b4e96b477631c464ab933ed 100644 (file)
@@ -38,11 +38,19 @@ template<class T>
 concept has_alt_fmt_print = requires(T t) {
   { t.alt_fmt_print(bool{}) } -> std::same_as<std::string>;
 };
+#if FMT_VERSION >= 110000
+template<class T>
+concept has_fmt_print_ctx = requires(
+  T t, fmt::buffered_context<char> &ctx) {
+  { t.fmt_print_ctx(ctx) } -> std::same_as<decltype(ctx.out())>;
+};
+#else
 template<class T>
 concept has_fmt_print_ctx = requires(
   T t, fmt::buffer_context<char> &ctx) {
   { t.fmt_print_ctx(ctx) } -> std::same_as<decltype(ctx.out())>;
 };
+#endif
 
 namespace fmt {
 
index e7a98d2097d2b41af390879b94f2247d5a23d1da..9d49d1bf050f7c122b816644ad85d8a802a07c92 100644 (file)
@@ -23,7 +23,7 @@ struct fmt::formatter<utime_t> {
   }
 
   template <typename FormatContext>
-  auto format(const utime_t& utime, FormatContext& ctx)
+  auto format(const utime_t& utime, FormatContext& ctx) const
   {
     if (utime.sec() < ((time_t)(60 * 60 * 24 * 365 * 10))) {
       // raw seconds.  this looks like a relative time.
index 78557f90e48f07ea15ef217140c68f9eaa180ffd..3e5c58ec376b4be8e04c291434a511aa99598d75 100644 (file)
@@ -617,7 +617,7 @@ struct formatter<M> {
     std::ostringstream oss;
     m.print(oss);
     if (auto ver = m.get_header().version; ver) {
-      return fmt::format_to(ctx.out(), "{} v{}", oss.str(), ver);
+      return fmt::format_to(ctx.out(), "{} v{}", oss.str(), (uint32_t)ver);
     } else {
       return fmt::format_to(ctx.out(), "{}", oss.str());
     }
index e0c41fdb64c173b1de4a0832c0bf43211a50e87c..ef4a6ddabfb5e9bc9371f157382587d1249f1dbb 100644 (file)
@@ -306,7 +306,7 @@ Tag FrameAssembler::disassemble_preamble(bufferlist& preamble_bl) {
       sizeof(*preamble) - sizeof(preamble->crc));
   if (crc != preamble->crc) {
     throw FrameError(fmt::format(
-        "bad preamble crc calculated={} expected={}", crc, preamble->crc));
+        "bad preamble crc calculated={} expected={}", crc, (uint32_t)preamble->crc));
   }
 
   // see calc_num_segments()
index 41c4c6af89debbf4648c39097a21f0916c6a9cf1..4c6c7d23026576db2db98ddb721d1fe85b5605e2 100644 (file)
@@ -15,7 +15,7 @@ struct fmt::formatter<entity_name_t> {
   constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
 
   template <typename FormatContext>
-  auto format(const entity_name_t& addr, FormatContext& ctx)
+  auto format(const entity_name_t& addr, FormatContext& ctx) const
   {
     if (addr.is_new() || addr.num() < 0) {
       return fmt::format_to(ctx.out(), "{}.?", addr.type_str());