[RFC PATCH v3 08/22] rust: capnp: return an error when trying to display floating point values

From: Ariel Miculas
Date: Thu May 16 2024 - 15:08:28 EST


The kernel doesn't support floating point values, so return an error
when the kernel feature is enabled.

Signed-off-by: Ariel Miculas <amiculas@xxxxxxxxx>
---
rust/capnp/stringify.rs | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/rust/capnp/stringify.rs b/rust/capnp/stringify.rs
index 426025fea0e8..f93e3521ce0b 100644
--- a/rust/capnp/stringify.rs
+++ b/rust/capnp/stringify.rs
@@ -71,8 +71,12 @@ pub(crate) fn print(
dynamic_value::Reader::UInt16(x) => formatter.write_fmt(format_args!("{x}")),
dynamic_value::Reader::UInt32(x) => formatter.write_fmt(format_args!("{x}")),
dynamic_value::Reader::UInt64(x) => formatter.write_fmt(format_args!("{x}")),
+ #[cfg(not(feature = "kernel"))]
dynamic_value::Reader::Float32(x) => formatter.write_fmt(format_args!("{x}")),
+ #[cfg(not(feature = "kernel"))]
dynamic_value::Reader::Float64(x) => formatter.write_fmt(format_args!("{x}")),
+ #[cfg(feature = "kernel")]
+ dynamic_value::Reader::Float32(_) | dynamic_value::Reader::Float64(_) => Err(fmt::Error),
dynamic_value::Reader::Enum(e) => match cvt(e.get_enumerant())? {
Some(enumerant) => {
formatter.write_str(cvt(cvt(enumerant.get_proto().get_name())?.to_str())?)
--
2.34.1