Skip to content

Commit

Permalink
fix: check the length of array properly
Browse files Browse the repository at this point in the history
Signed-off-by: Yuuki Takano <yuuki.takano@tier4.jp>
  • Loading branch information
ytakano committed May 7, 2024
1 parent 5ee7aa2 commit 80786c4
Show file tree
Hide file tree
Showing 37 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ macro_rules! def_sequence {

impl<const N: usize> $ty<N> {
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -383,7 +383,7 @@ pub struct RosStringSeq<const STRLEN: usize, const SEQLEN: usize>(

impl<const STRLEN: usize, const SEQLEN: usize> RosStringSeq<STRLEN, SEQLEN> {
pub fn new(size: usize) -> Option<Self> {
if SEQLEN != 0 && size >= SEQLEN {
if SEQLEN != 0 && size > SEQLEN {
// the size exceeds in the maximum number
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/msg/humble/interfaces/action_msgs/msg/goal_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<const N: usize> GoalInfoSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/msg/humble/interfaces/action_msgs/msg/goal_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<const N: usize> GoalStatusSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<const N: usize> GoalStatusArraySeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
4 changes: 2 additions & 2 deletions src/msg/humble/interfaces/action_msgs/srv/cancel_goal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<const N: usize> CancelGoalRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -203,7 +203,7 @@ impl<const N: usize> CancelGoalResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<const N: usize> ListNodesRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -204,7 +204,7 @@ impl<const N: usize> ListNodesResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<const N: usize> LoadNodeRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -213,7 +213,7 @@ impl<const N: usize> LoadNodeResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<const N: usize> UnloadNodeRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -206,7 +206,7 @@ impl<const N: usize> UnloadNodeResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/msg/humble/interfaces/lifecycle_msgs/msg/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<const N: usize> StateSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/msg/humble/interfaces/lifecycle_msgs/msg/transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<const N: usize> TransitionSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<const N: usize> TransitionDescriptionSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<const N: usize> TransitionEventSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
4 changes: 2 additions & 2 deletions src/msg/humble/interfaces/lifecycle_msgs/srv/change_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<const N: usize> ChangeStateRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ impl<const N: usize> ChangeStateResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<const N: usize> GetAvailableStatesRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -209,7 +209,7 @@ impl<const N: usize> GetAvailableStatesResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<const N: usize> GetAvailableTransitionsRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -213,7 +213,7 @@ impl<const N: usize> GetAvailableTransitionsResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
4 changes: 2 additions & 2 deletions src/msg/humble/interfaces/lifecycle_msgs/srv/get_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl<const N: usize> GetStateRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ impl<const N: usize> GetStateResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<const N: usize> FloatingPointRangeSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<const N: usize> IntegerRangeSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<const N: usize> ListParametersResultSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/msg/humble/interfaces/rcl_interfaces/msg/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<const N: usize> LogSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/msg/humble/interfaces/rcl_interfaces/msg/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<const N: usize> ParameterSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<const N: usize> ParameterDescriptorSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<const N: usize> ParameterEventSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<const N: usize> ParameterEventDescriptorsSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl<const N: usize> ParameterTypeSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<const N: usize> ParameterValueSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<const N: usize> SetParametersResultSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<const N: usize> DescribeParametersRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -209,7 +209,7 @@ impl<const N: usize> DescribeParametersResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<const N: usize> GetParameterTypesRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ impl<const N: usize> GetParameterTypesResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<const N: usize> GetParametersRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -203,7 +203,7 @@ impl<const N: usize> GetParametersResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<const N: usize> ListParametersRequestSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down Expand Up @@ -206,7 +206,7 @@ impl<const N: usize> ListParametersResponseSeq<N> {
/// `N` represents the maximum number of elements.
/// If `N` is `0`, the sequence is unlimited.
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size >= N {
if N != 0 && size > N {
// the size exceeds in the maximum number
return None;
}
Expand Down
Loading

0 comments on commit 80786c4

Please sign in to comment.