Skip to content

Commit

Permalink
prevent overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
HarishgunaS committed Oct 13, 2023
1 parent a42a251 commit 8c8eeaa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ptp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl EthernetPTP {

impl<'a> EthernetPTP {
pub fn get_frame_from<const TD: usize, const RD: usize>(dma: &'a EthernetDMA<TD, RD>, clock_identity: u64) -> Option<PtpFrame> {
let mut i = dma.write_pos + 1;
let mut i = (dma.write_pos + 1) % MAX_PTP_FOLLOWERS;
loop {
if dma.ptp_frame_buffer[i].meta_option.is_some() {
if dma.ptp_frame_buffer[i].clock_identity == clock_identity {
Expand All @@ -347,7 +347,7 @@ impl<'a> EthernetPTP {
return None;
}
pub fn invalidate_frame_from<const TD: usize, const RD: usize>(dma: &'a mut EthernetDMA<TD, RD>, clock_identity: u64) {
let mut i = dma.write_pos + 1;
let mut i = (dma.write_pos + 1) % MAX_PTP_FOLLOWERS;
loop {
if dma.ptp_frame_buffer[i].meta_option.is_some() {
if dma.ptp_frame_buffer[i].clock_identity == clock_identity {
Expand Down

0 comments on commit 8c8eeaa

Please sign in to comment.