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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux