diff options
author | asynts <asynts@gmail.com> | 2021-01-11 13:32:26 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-11 21:49:29 +0100 |
commit | 843ebbd2c3e8b20cfb5415468c1c8c32e2aa1a4d (patch) | |
tree | 2f0a194a11dcd29658f77387853bd75447bef153 /Libraries | |
parent | 6fa42af5674ab684b45f9745dc68b0d3fa0605b8 (diff) | |
download | serenity-843ebbd2c3e8b20cfb5415468c1c8c32e2aa1a4d.zip |
Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp | 12 | ||||
-rw-r--r-- | Libraries/LibCrypto/BigInt/UnsignedBigInteger.h | 5 | ||||
-rw-r--r-- | Libraries/LibCrypto/PK/RSA.cpp | 16 | ||||
-rw-r--r-- | Libraries/LibCrypto/PK/RSA.h | 2 | ||||
-rw-r--r-- | Libraries/LibELF/DynamicLoader.cpp | 1 | ||||
-rw-r--r-- | Libraries/LibGUI/ColumnsView.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibGUI/Desktop.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibGUI/Dialog.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibGUI/Dialog.h | 4 | ||||
-rw-r--r-- | Libraries/LibGUI/FileSystemModel.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibGemini/Line.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibGfx/Bitmap.cpp | 9 | ||||
-rw-r--r-- | Libraries/LibGfx/BitmapFont.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibGfx/ShareableBitmap.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibGfx/SystemTheme.cpp | 2 |
15 files changed, 46 insertions, 21 deletions
diff --git a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp index 23ab7d2a8d..ef838ec782 100644 --- a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp +++ b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp @@ -731,3 +731,15 @@ ALWAYS_INLINE u32 UnsignedBigInteger::shift_left_get_one_word( return result; } } + +void AK::Formatter<Crypto::UnsignedBigInteger>::format(FormatBuilder& fmtbuilder, const Crypto::UnsignedBigInteger& value) +{ + if (value.is_invalid()) + return Formatter<StringView>::format(fmtbuilder, "invalid"); + + StringBuilder builder; + for (int i = value.length() - 1; i >= 0; --i) + builder.appendff("{}|", value.words()[i]); + + return Formatter<StringView>::format(fmtbuilder, builder.string_view()); +} diff --git a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h index 86789422f8..07d2ca4848 100644 --- a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h +++ b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h @@ -144,6 +144,11 @@ operator<<(const LogStream& stream, const Crypto::UnsignedBigInteger& value) return stream; } +template<> +struct AK::Formatter<Crypto::UnsignedBigInteger> : Formatter<StringView> { + void format(FormatBuilder&, const Crypto::UnsignedBigInteger&); +}; + inline Crypto::UnsignedBigInteger operator""_bigint(const char* string, size_t length) { diff --git a/Libraries/LibCrypto/PK/RSA.cpp b/Libraries/LibCrypto/PK/RSA.cpp index d1ca1ab629..452da97acc 100644 --- a/Libraries/LibCrypto/PK/RSA.cpp +++ b/Libraries/LibCrypto/PK/RSA.cpp @@ -51,7 +51,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in) ASN1::set(pubkey[0], ASN1::Kind::Sequence, &pubkey_hash_oid, 2); ASN1::set(pubkey[1], ASN1::Kind::Null, nullptr, 0); - dbg() << "we were offered " << in.size() << " bytes of input"; + dbgln("we were offered {} bytes of input", in.size()); if (der_decode_sequence(in.data(), in.size(), pubkey, 2)) { // yay, now we have to reassemble the bitstring to a bytestring @@ -72,7 +72,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in) ASN1::Kind::Integer, 1, &n, ASN1::Kind::Integer, 1, &e)) { // something was fucked up - dbg() << "bad pubkey: " << e << " in " << n; + dbgln("bad pubkey: e={} n={}", e, n); return keypair; } // correct public key @@ -97,7 +97,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in) ASN1::Kind::Integer, 1, &n, ASN1::Kind::Integer, 1, &e, ASN1::Kind::Integer, 1, &d)) { - dbg() << "bad privkey " << n << " " << e << " " << d; + dbgln("bad privkey n={} e={} d={}", n, e, d); return keypair; } keypair.private_key.set(n, d, e); @@ -128,7 +128,7 @@ void RSA::encrypt(ReadonlyBytes in, Bytes& out) auto size = exp.export_data(out); auto outsize = out.size(); if (size != outsize) { - dbg() << "POSSIBLE RSA BUG!!! Size mismatch: " << outsize << " requested but " << size << " bytes generated"; + dbgln("POSSIBLE RSA BUG!!! Size mismatch: {} requested but {} bytes generated", outsize, size); out = out.slice(outsize - size, size); } } @@ -275,7 +275,7 @@ void RSA_PKCS1_EME::decrypt(ReadonlyBytes in, Bytes& out) { auto mod_len = (m_public_key.modulus().trimmed_length() * sizeof(u32) * 8 + 7) / 8; if (in.size() != mod_len) { - dbg() << "decryption error: wrong amount of data: " << in.size(); + dbgln("decryption error: wrong amount of data: {}", in.size()); out = out.trim(0); return; } @@ -283,18 +283,18 @@ void RSA_PKCS1_EME::decrypt(ReadonlyBytes in, Bytes& out) RSA::decrypt(in, out); if (out.size() < RSA::output_size()) { - dbg() << "decryption error: not enough data after decryption: " << out.size(); + dbgln("decryption error: not enough data after decryption: {}", out.size()); out = out.trim(0); return; } if (out[0] != 0x00) { - dbg() << "invalid padding byte 0 : " << out[0]; + dbgln("invalid padding byte 0 : {}", out[0]); return; } if (out[1] != 0x02) { - dbg() << "invalid padding byte 1" << out[1]; + dbgln("invalid padding byte 1 : {}", out[1]); return; } diff --git a/Libraries/LibCrypto/PK/RSA.h b/Libraries/LibCrypto/PK/RSA.h index 1808a653af..570e0be423 100644 --- a/Libraries/LibCrypto/PK/RSA.h +++ b/Libraries/LibCrypto/PK/RSA.h @@ -137,7 +137,7 @@ public: auto n = p.multiplied_by(q); auto d = NumberTheory::ModularInverse(e, lambda); - dbg() << "Your keys are Pub{n=" << n << ", e=" << e << "} and Priv{n=" << n << ", d=" << d << "}"; + dbgln("Your keys are Pub(n={}, e={}) and Priv(n={}, d={})", n, e, n, d); RSAKeyPair<PublicKeyType, PrivateKeyType> keys { { n, e }, { n, d, e } diff --git a/Libraries/LibELF/DynamicLoader.cpp b/Libraries/LibELF/DynamicLoader.cpp index 586b98d089..e7c56a370c 100644 --- a/Libraries/LibELF/DynamicLoader.cpp +++ b/Libraries/LibELF/DynamicLoader.cpp @@ -180,7 +180,6 @@ bool DynamicLoader::load_stage_2(unsigned flags, size_t total_tls_size) #endif if (m_dynamic_object->has_text_relocations()) { - // dbg() << "Someone linked non -fPIC code into " << m_filename << " :("; ASSERT(m_text_segment_load_address.get() != 0); #ifndef AK_OS_MACOS diff --git a/Libraries/LibGUI/ColumnsView.cpp b/Libraries/LibGUI/ColumnsView.cpp index 7e702f9abb..9a18c4a5f3 100644 --- a/Libraries/LibGUI/ColumnsView.cpp +++ b/Libraries/LibGUI/ColumnsView.cpp @@ -188,7 +188,7 @@ void ColumnsView::push_column(const ModelIndex& parent_index) if (m_columns[i].parent_index == grandparent) break; m_columns.shrink(i); - dbg() << "Dropping column " << i; + dbgln("Dropping column {}", i); } // Add the new column. diff --git a/Libraries/LibGUI/Desktop.cpp b/Libraries/LibGUI/Desktop.cpp index 5f882c366b..f0bb7b4759 100644 --- a/Libraries/LibGUI/Desktop.cpp +++ b/Libraries/LibGUI/Desktop.cpp @@ -71,7 +71,7 @@ bool Desktop::set_wallpaper(const StringView& path, bool save_config) if (ret_val && save_config) { RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("WindowManager"); - dbg() << "Saving wallpaper path '" << path << "' to config file at " << config->file_name(); + dbgln("Saving wallpaper path '{}' to config file at {}", path, config->file_name()); config->write_entry("Background", "Wallpaper", path); config->sync(); } diff --git a/Libraries/LibGUI/Dialog.cpp b/Libraries/LibGUI/Dialog.cpp index 7de39c682d..e1988da503 100644 --- a/Libraries/LibGUI/Dialog.cpp +++ b/Libraries/LibGUI/Dialog.cpp @@ -58,7 +58,7 @@ int Dialog::exec() show(); auto result = m_event_loop->exec(); m_event_loop = nullptr; - dbg() << *this << ": Event loop returned with result " << result; + dbgln("{}: Event loop returned with result {}", *this, result); remove_from_parent(); return result; } @@ -68,7 +68,7 @@ void Dialog::done(int result) if (!m_event_loop) return; m_result = result; - dbg() << *this << ": Quit event loop with result " << result; + dbgln("{}: Quit event loop with result {}", *this, result); m_event_loop->quit(result); } diff --git a/Libraries/LibGUI/Dialog.h b/Libraries/LibGUI/Dialog.h index 857177d64c..76ee87919a 100644 --- a/Libraries/LibGUI/Dialog.h +++ b/Libraries/LibGUI/Dialog.h @@ -61,3 +61,7 @@ private: }; } + +template<> +struct AK::Formatter<GUI::Dialog> : Formatter<Core::Object> { +}; diff --git a/Libraries/LibGUI/FileSystemModel.cpp b/Libraries/LibGUI/FileSystemModel.cpp index a7e2b85852..1a4934da2d 100644 --- a/Libraries/LibGUI/FileSystemModel.cpp +++ b/Libraries/LibGUI/FileSystemModel.cpp @@ -145,7 +145,7 @@ void FileSystemModel::Node::traverse_if_needed() return; } fcntl(m_watch_fd, F_SETFD, FD_CLOEXEC); - dbg() << "Watching " << full_path << " for changes, m_watch_fd = " << m_watch_fd; + dbgln("Watching {} for changes, m_watch_fd={}", full_path, m_watch_fd); m_notifier = Core::Notifier::construct(m_watch_fd, Core::Notifier::Event::Read); m_notifier->on_ready_to_read = [this] { char buffer[32]; diff --git a/Libraries/LibGemini/Line.cpp b/Libraries/LibGemini/Line.cpp index d663184b2c..d3197176d5 100644 --- a/Libraries/LibGemini/Line.cpp +++ b/Libraries/LibGemini/Line.cpp @@ -80,7 +80,7 @@ String Control::render_to_html() const case Kind::UnorderedListEnd: return "</ul>"; default: - dbg() << "Unknown control kind _" << m_kind << "_"; + dbgln("Unknown control kind _{}_", (int)m_kind); ASSERT_NOT_REACHED(); return ""; } diff --git a/Libraries/LibGfx/Bitmap.cpp b/Libraries/LibGfx/Bitmap.cpp index 57cf9dcf90..7c031f59be 100644 --- a/Libraries/LibGfx/Bitmap.cpp +++ b/Libraries/LibGfx/Bitmap.cpp @@ -170,8 +170,13 @@ static bool check_size(const IntSize& size, BitmapFormat format, unsigned actual unsigned expected_size_max = round_up_to_power_of_two(expected_size_min, PAGE_SIZE); if (expected_size_min > actual_size || actual_size > expected_size_max) { // Getting here is most likely an error. - dbg() << "Constructing a shared bitmap for format " << (int)format << " and size " << size << ", which demands " << expected_size_min << " bytes, which rounds up to at most " << expected_size_max << "."; - dbg() << "However, we were given " << actual_size << " bytes, which is outside this range?! Refusing cowardly."; + dbgln("Constructing a shared bitmap for format {} and size {}, which demands {} bytes, which rounds up to at most {}.", + static_cast<int>(format), + size, + expected_size_min, + expected_size_max); + + dbgln("However, we were given {} bytes, which is outside this range?! Refusing cowardly.", actual_size); return false; } return true; diff --git a/Libraries/LibGfx/BitmapFont.cpp b/Libraries/LibGfx/BitmapFont.cpp index 42fefc1530..e5e24cbde5 100644 --- a/Libraries/LibGfx/BitmapFont.cpp +++ b/Libraries/LibGfx/BitmapFont.cpp @@ -167,7 +167,7 @@ size_t BitmapFont::glyph_count_by_type(FontTypes type) if (type == FontTypes::LatinExtendedA) return 384; - dbg() << "Unknown font type:" << type; + dbgln("Unknown font type: {}", (int)type); ASSERT_NOT_REACHED(); } diff --git a/Libraries/LibGfx/ShareableBitmap.cpp b/Libraries/LibGfx/ShareableBitmap.cpp index 662a294f25..6413140827 100644 --- a/Libraries/LibGfx/ShareableBitmap.cpp +++ b/Libraries/LibGfx/ShareableBitmap.cpp @@ -62,7 +62,7 @@ bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap) if (shbuf_id == -1) return true; - dbg() << "Decoding a ShareableBitmap with shbuf_id=" << shbuf_id << ", size=" << size; + dbgln("Decoding a ShareableBitmap with shbuf_id={}, size={}", shbuf_id, size); auto shared_buffer = SharedBuffer::create_from_shbuf_id(shbuf_id); if (!shared_buffer) diff --git a/Libraries/LibGfx/SystemTheme.cpp b/Libraries/LibGfx/SystemTheme.cpp index ab9527b58b..5ccb04256d 100644 --- a/Libraries/LibGfx/SystemTheme.cpp +++ b/Libraries/LibGfx/SystemTheme.cpp @@ -79,7 +79,7 @@ RefPtr<SharedBuffer> load_system_theme(const String& path) case (int)MetricRole::TitleButtonWidth: return 15; default: - dbg() << "Metric " << name << " has no fallback value!"; + dbgln("Metric {} has no fallback value!", name); return 16; } } |