From f7b4eb6aac3b695d65b5411fabbd9014dfc2b204 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 12 May 2022 20:52:50 +0200 Subject: [PATCH 1/2] `str` should not include NULL byte. --- ublox/src/ubx_packets/packets.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ublox/src/ubx_packets/packets.rs b/ublox/src/ubx_packets/packets.rs index 247d151..19fd0f0 100644 --- a/ublox/src/ubx_packets/packets.rs +++ b/ublox/src/ubx_packets/packets.rs @@ -1783,7 +1783,7 @@ mod mon_ver { .iter() .position(|x| *x == 0) .expect("is_cstr_valid bug?"); - core::str::from_utf8(&bytes[0..=null_pos]) + core::str::from_utf8(&bytes[0..null_pos]) .expect("is_cstr_valid should have prevented this code from running") } @@ -1794,7 +1794,7 @@ mod mon_ver { return false; } }; - core::str::from_utf8(&bytes[0..=null_pos]).is_ok() + core::str::from_utf8(&bytes[0..null_pos]).is_ok() } pub(crate) fn is_extension_valid(payload: &[u8]) -> bool { From fa951af5c059037a2604d1cd1dc5d0c8dfe952da Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 12 May 2022 21:34:39 +0200 Subject: [PATCH 2/2] Fix trailing spaces. --- ublox/src/ubx_packets/packets.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ublox/src/ubx_packets/packets.rs b/ublox/src/ubx_packets/packets.rs index 19fd0f0..383f0fb 100644 --- a/ublox/src/ubx_packets/packets.rs +++ b/ublox/src/ubx_packets/packets.rs @@ -764,8 +764,8 @@ bitflags! { flags = "default_for_builder" )] struct InfError{ - #[ubx(map_type = Option<&str>, - may_fail, + #[ubx(map_type = Option<&str>, + may_fail, is_valid = inf::is_valid, from = inf::convert_to_str, get_as_ref)] @@ -780,8 +780,8 @@ struct InfError{ flags = "default_for_builder" )] struct InfNotice{ - #[ubx(map_type = Option<&str>, - may_fail, + #[ubx(map_type = Option<&str>, + may_fail, is_valid = inf::is_valid, from = inf::convert_to_str, get_as_ref)] @@ -796,8 +796,8 @@ struct InfNotice{ flags = "default_for_builder" )] struct InfTest{ - #[ubx(map_type = Option<&str>, - may_fail, + #[ubx(map_type = Option<&str>, + may_fail, is_valid = inf::is_valid, from = inf::convert_to_str, get_as_ref)] @@ -812,8 +812,8 @@ struct InfTest{ flags = "default_for_builder" )] struct InfWarning{ - #[ubx(map_type = Option<&str>, - may_fail, + #[ubx(map_type = Option<&str>, + may_fail, is_valid = inf::is_valid, from = inf::convert_to_str, get_as_ref)] @@ -828,8 +828,8 @@ struct InfWarning{ flags = "default_for_builder" )] struct InfDebug{ - #[ubx(map_type = Option<&str>, - may_fail, + #[ubx(map_type = Option<&str>, + may_fail, is_valid = inf::is_valid, from = inf::convert_to_str, get_as_ref)] @@ -1608,7 +1608,7 @@ struct CfgNavX5 { reserved8: [u8; 4], reserved9: [u8; 3], - /// Enable/disable ADR/UDR sensor fusion + /// Enable/disable ADR/UDR sensor fusion use_adr: u8, }