From: Adam Kupczyk Date: Thu, 4 Jul 2024 17:47:29 +0000 (+0000) Subject: include/denc: Not use fmt::format X-Git-Tag: v20.0.0~1498^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=71ca41dbaa5640cc41589d9c2b04ca1b2967ab16;p=ceph.git 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 --- diff --git a/src/include/denc.h b/src/include/denc.h index 00a290165655..cdc54a55129e 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()); \ } \