summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2023-01-13 02:19:40 +0000
committerLinus Groh <mail@linusgroh.de>2023-01-13 21:09:26 +0000
commit9a120d7243ea28ac61a8bda477910ee2c7ea159b (patch)
tree0acd906b498f83bd871d0eb4035ecf81218addb8 /Kernel
parent13883753109ae1253d0f36a5cc9e4a45b3084c12 (diff)
downloadserenity-9a120d7243ea28ac61a8bda477910ee2c7ea159b.zip
AK: Add support for "debug only" formatters
These are formatters that can only be used with debug print functions, such as dbgln(). Currently this is limited to Formatter<ErrorOr<T>>. With this you can still debug log ErrorOr values (good for debugging), but trying to use them in any String::formatted() call will fail (which prevents .to_string() errors with the new failable strings being ignored). You make a formatter debug only by adding a constexpr method like: static constexpr bool is_debug_only() { return true; }
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Bus/PCI/Device.h2
-rw-r--r--Kernel/KBufferBuilder.h2
-rw-r--r--Kernel/KString.h2
3 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/Bus/PCI/Device.h b/Kernel/Bus/PCI/Device.h
index 9c1d1fa92e..61a713b664 100644
--- a/Kernel/Bus/PCI/Device.h
+++ b/Kernel/Bus/PCI/Device.h
@@ -48,7 +48,7 @@ void dmesgln_pci(Device const& device, AK::CheckedFormatString<Parameters...>&&
return;
if (builder.try_append(fmt.view()).is_error())
return;
- AK::VariadicFormatParams variadic_format_params { device.device_name(), device.pci_address(), parameters... };
+ AK::VariadicFormatParams<AK::AllowDebugOnlyFormatters::Yes, StringView, Address, Parameters...> variadic_format_params { device.device_name(), device.pci_address(), parameters... };
vdmesgln(builder.string_view(), variadic_format_params);
}
diff --git a/Kernel/KBufferBuilder.h b/Kernel/KBufferBuilder.h
index 426b7c8d9b..f5e6d10f48 100644
--- a/Kernel/KBufferBuilder.h
+++ b/Kernel/KBufferBuilder.h
@@ -37,7 +37,7 @@ public:
{
// FIXME: This really not ideal, but vformat expects StringBuilder.
StringBuilder builder;
- AK::VariadicFormatParams variadic_format_params { parameters... };
+ AK::VariadicFormatParams<AK::AllowDebugOnlyFormatters::No, Parameters...> variadic_format_params { parameters... };
TRY(vformat(builder, fmtstr.view(), variadic_format_params));
return append_bytes(builder.string_view().bytes());
}
diff --git a/Kernel/KString.h b/Kernel/KString.h
index 2639f9617b..7905936dbe 100644
--- a/Kernel/KString.h
+++ b/Kernel/KString.h
@@ -26,7 +26,7 @@ public:
template<typename... Parameters>
[[nodiscard]] static ErrorOr<NonnullOwnPtr<KString>> formatted(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
{
- AK::VariadicFormatParams variadic_format_parameters { parameters... };
+ AK::VariadicFormatParams<AK::AllowDebugOnlyFormatters::No, Parameters...> variadic_format_parameters { parameters... };
return vformatted(fmtstr.view(), variadic_format_parameters);
}