diff mbox series

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

Message ID 20240516190345.957477-9-amiculas@cisco.com (mailing list archive)
State New, archived
Headers show
Series Rust PuzzleFS filesystem driver | expand

Commit Message

Ariel Miculas May 16, 2024, 7:03 p.m. UTC
The kernel doesn't support floating point values, so return an error
when the kernel feature is enabled.

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

Patch

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())?)