diff --git a/benchmark/bench_actor.cpp b/benchmark/bench_actor.cpp index b397737fc..a966d601c 100644 --- a/benchmark/bench_actor.cpp +++ b/benchmark/bench_actor.cpp @@ -32,7 +32,7 @@ class RingBench : public td::Benchmark { std::string get_description() const override { static const char *types[] = {"later", "immediate", "raw", "tail", "lambda"}; static_assert(0 <= type && type < 5, ""); - return PSTRING("Ring (send_%s) (threads_n = %d)", types[type], thread_n_); + return PSTRING() << "Ring (send_" << types[type] << ") (threads_n = " << thread_n_ << ")"; } struct PassActor : public td::Actor { diff --git a/benchmark/bench_crypto.cpp b/benchmark/bench_crypto.cpp index 07d9dbea0..44d309ef1 100644 --- a/benchmark/bench_crypto.cpp +++ b/benchmark/bench_crypto.cpp @@ -30,7 +30,7 @@ class SHA1Bench : public td::Benchmark { alignas(64) unsigned char data[DATA_SIZE]; std::string get_description() const override { - return PSTRING("SHA1 OpenSSL [%dKB]", DATA_SIZE >> 10); + return PSTRING() << "SHA1 OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; } void start_up() override { @@ -55,7 +55,7 @@ class AESBench : public td::Benchmark { td::UInt256 iv; std::string get_description() const override { - return PSTRING("AES OpenSSL [%dKB]", DATA_SIZE >> 10); + return PSTRING() << "AES OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; } void start_up() override { @@ -152,7 +152,7 @@ class Crc32Bench : public td::Benchmark { alignas(64) unsigned char data[DATA_SIZE]; std::string get_description() const override { - return PSTRING("Crc32 zlib [%dKB]", DATA_SIZE >> 10); + return PSTRING() << "Crc32 zlib [" << (DATA_SIZE >> 10) << "KB]"; } void start_up() override { @@ -176,7 +176,7 @@ class Crc64Bench : public td::Benchmark { alignas(64) unsigned char data[DATA_SIZE]; std::string get_description() const override { - return PSTRING("Crc64 Anton [%dKB]", DATA_SIZE >> 10); + return PSTRING() << "Crc64 Anton [" << (DATA_SIZE >> 10) << "KB]"; } void start_up() override { diff --git a/tdnet/td/net/SslFd.cpp b/tdnet/td/net/SslFd.cpp index 4e5d56792..f6f755723 100644 --- a/tdnet/td/net/SslFd.cpp +++ b/tdnet/td/net/SslFd.cpp @@ -149,7 +149,7 @@ Result SslFd::init(SocketFd fd, CSlice host, CSlice cert_file, VerifyPeer // TODO(now): cipher list string cipher_list; if (SSL_CTX_set_cipher_list(ssl_ctx, cipher_list.empty() ? "DEFAULT" : cipher_list.c_str()) == 0) { - return create_openssl_error(-9, PSLICE("Failed to set cipher list \"%s\"", cipher_list.c_str())); + return create_openssl_error(-9, PSLICE() << "Failed to set cipher list \"" << cipher_list << '"'); } auto ssl_handle = SSL_new(ssl_ctx); diff --git a/tdutils/td/utils/Closure.h b/tdutils/td/utils/Closure.h index 712073643..8bf024e09 100644 --- a/tdutils/td/utils/Closure.h +++ b/tdutils/td/utils/Closure.h @@ -129,14 +129,16 @@ class DelayedClosure { explicit DelayedClosure( const DelayedClosure &other, std::enable_if_t::value...>::value, int> = 0) { - UNREACHABLE("deleted constructor"); + LOG(FATAL) << "Deleted constructor"; + std::abort(); } template std::enable_if_t::value...>::value, DelayedClosure> do_clone(const DelayedClosure &value) const { - UNREACHABLE("Trying to clone DelayedClosure that contains noncopyable elements"); + LOG(FATAL) << "Trying to clone DelayedClosure that contains noncopyable elements"; + std::abort(); } template diff --git a/tdutils/td/utils/port/Fd.cpp b/tdutils/td/utils/port/Fd.cpp index 9b1531cb6..a7fb51efe 100644 --- a/tdutils/td/utils/port/Fd.cpp +++ b/tdutils/td/utils/port/Fd.cpp @@ -286,7 +286,7 @@ Result Fd::write_unsafe(Slice slice) { if (write_res >= 0) { return narrow_cast(write_res); } - return Status::PosixError(write_errno, PSLICE("Write to [fd=%d] has failed", native_fd)); + return Status::PosixError(write_errno, PSLICE() << "Write to fd " << native_fd << " has failed"); } Result Fd::write(Slice slice) { @@ -306,7 +306,7 @@ Result Fd::write(Slice slice) { return 0; } - auto error = Status::PosixError(write_errno, PSLICE("Write to [fd=%d] has failed", native_fd)); + auto error = Status::PosixError(write_errno, PSLICE() << "Write to fd " << native_fd << " has failed"); switch (write_errno) { case EBADF: case ENXIO: @@ -352,7 +352,7 @@ Result Fd::read(MutableSlice slice) { clear_flags(Read); return 0; } - auto error = Status::PosixError(read_errno, PSLICE("Read from [fd=%d] has failed", native_fd)); + auto error = Status::PosixError(read_errno, PSLICE() << "Read from fd " << native_fd << " has failed"); switch (read_errno) { case EISDIR: case EBADF: diff --git a/tdutils/td/utils/port/IPAddress.cpp b/tdutils/td/utils/port/IPAddress.cpp index 1b8c04f8d..7995c99d3 100644 --- a/tdutils/td/utils/port/IPAddress.cpp +++ b/tdutils/td/utils/port/IPAddress.cpp @@ -44,7 +44,8 @@ size_t IPAddress::get_sockaddr_len() const { case AF_INET: return sizeof(ipv4_addr_); default: - UNREACHABLE("Unknown address family"); + LOG(FATAL) << "Unknown address family"; + return 0; } } @@ -79,7 +80,7 @@ IPAddress IPAddress::get_any_addr() const { res.init_ipv4_any(); break; default: - UNREACHABLE("Unknown address family"); + LOG(FATAL) << "Unknown address family"; } return res; } @@ -317,7 +318,7 @@ bool operator==(const IPAddress &a, const IPAddress &b) { std::memcmp(&a.ipv6_addr_.sin6_addr, &b.ipv6_addr_.sin6_addr, sizeof(a.ipv6_addr_.sin6_addr)) == 0; } - UNREACHABLE("Unknown address family"); + LOG(FATAL) << "Unknown address family"; return false; } @@ -341,7 +342,7 @@ bool operator<(const IPAddress &a, const IPAddress &b) { return std::memcmp(&a.ipv6_addr_.sin6_addr, &b.ipv6_addr_.sin6_addr, sizeof(a.ipv6_addr_.sin6_addr)) < 0; } - UNREACHABLE("Unknown address family"); + LOG(FATAL) << "Unknown address family"; return false; }