From 71ca41dbaa5640cc41589d9c2b04ca1b2967ab16 Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Thu, 4 Jul 2024 17:47:29 +0000 Subject: [PATCH] include/denc: Not use fmt::format fmt::format caused linking problems in some compilations. Instead of fixing them all, discontinue usage. Moved compatibility throw to separate function. Signed-off-by: Adam Kupczyk --- src/include/denc.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/include/denc.h b/src/include/denc.h index 00a29016565..cdc54a55129 100644 --- a/src/include/denc.h +++ b/src/include/denc.h @@ -51,6 +51,7 @@ #include "common/convenience.h" #include "common/error_code.h" +#include "common/likely.h" #include "ceph_release.h" template @@ -1782,6 +1783,13 @@ inline std::enable_if_t decode_nohead( // wrappers for DENC_{START,FINISH} for inter-version // interoperability. +[[maybe_unused]] static void denc_compat_throw( + const char* _pretty_function_, uint8_t code_v, + uint8_t struct_v, uint8_t struct_compat) { + throw ::ceph::buffer::malformed_input("Decoder at '" + std::string(_pretty_function_) + + "' v=" + std::to_string(code_v)+ " cannot decode v=" + std::to_string(struct_v) + + " minimal_decoder=" + std::to_string(struct_compat)); +} #define DENC_HELPERS \ /* bound_encode */ \ static void _denc_start(size_t& p, \ @@ -1822,10 +1830,8 @@ inline std::enable_if_t decode_nohead( __u8 code_v = *struct_v; \ denc(*struct_v, p); \ denc(*struct_compat, p); \ - if (code_v < *struct_compat) \ - throw ::ceph::buffer::malformed_input(fmt::format( \ - "Decoder at '{}' v={} cannot decode v={} minimal_decoder={}", \ - __PRETTY_FUNCTION__, code_v, *struct_v, *struct_compat)); \ + if (unlikely(code_v < *struct_compat)) \ + denc_compat_throw(__PRETTY_FUNCTION__, code_v, *struct_v, *struct_compat);\ denc(*struct_len, p); \ *start_pos = const_cast(p.get_pos()); \ } \ -- 2.39.5