diff options
author | imarom <imarom@cisco.com> | 2015-12-22 08:28:01 -0500 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2015-12-23 09:59:41 -0500 |
commit | 61685c0768c0786859da8f6e7737cc909bd5ab26 (patch) | |
tree | e2b5a86774eed073be6b6c36955e5762feffc10d /src | |
parent | 16130b77af4f966b1f794f27b75265d76ee96dea (diff) |
VM wrap around issue
Diffstat (limited to 'src')
-rw-r--r-- | src/stateless/cp/trex_stream_vm.h | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/src/stateless/cp/trex_stream_vm.h b/src/stateless/cp/trex_stream_vm.h index a0e8b6b5..136389c5 100644 --- a/src/stateless/cp/trex_stream_vm.h +++ b/src/stateless/cp/trex_stream_vm.h @@ -47,18 +47,20 @@ public: void dump(FILE *fd,std::string opt); inline void run_inc(uint8_t * flow_var) { - uint8_t * p=(flow_var+m_flow_offset); - *p=*p+1; - if (*p>m_max_val) { - *p=m_min_val; + uint8_t *p = (flow_var + m_flow_offset); + if (*p == m_max_val) { + *p = m_min_val; + } else { + *p = *p + 1; } } inline void run_dec(uint8_t * flow_var) { - uint8_t * p=(flow_var+m_flow_offset); - *p=*p-1; - if (*p<m_min_val) { - *p=m_max_val; + uint8_t *p = (flow_var + m_flow_offset); + if (*p == m_min_val) { + *p = m_max_val; + } else { + *p = *p - 1; } } @@ -79,18 +81,20 @@ public: void dump(FILE *fd,std::string opt); inline void run_inc(uint8_t * flow_var) { - uint16_t * p=(uint16_t *)(flow_var+m_flow_offset); - *p=*p+1; - if (*p>m_max_val) { - *p=m_min_val; + uint16_t *p = (uint16_t *)(flow_var + m_flow_offset); + if (*p == m_max_val) { + *p = m_min_val; + } else { + *p = *p + 1; } } inline void run_dec(uint8_t * flow_var) { - uint16_t * p=(uint16_t *)(flow_var+m_flow_offset); - *p=*p-1; - if (*p<m_min_val) { - *p=m_max_val; + uint16_t *p = (uint16_t *)(flow_var + m_flow_offset); + if (*p == m_min_val) { + *p = m_max_val; + } else { + *p = *p - 1; } } @@ -112,18 +116,20 @@ public: void dump(FILE *fd,std::string opt); inline void run_inc(uint8_t * flow_var) { - uint32_t * p=(uint32_t *)(flow_var+m_flow_offset); - *p=*p+1; - if (*p>m_max_val) { - *p=m_min_val; + uint32_t *p = (uint32_t *)(flow_var + m_flow_offset); + if (*p == m_max_val) { + *p = m_min_val; + } else { + *p = *p + 1; } } inline void run_dec(uint8_t * flow_var) { - uint32_t * p=(uint32_t *)(flow_var+m_flow_offset); - *p=*p-1; - if (*p<m_min_val) { - *p=m_max_val; + uint32_t *p = (uint32_t *)(flow_var + m_flow_offset); + if (*p == m_min_val) { + *p = m_max_val; + } else { + *p = *p - 1; } } @@ -143,18 +149,20 @@ public: void dump(FILE *fd,std::string opt); inline void run_inc(uint8_t * flow_var) { - uint64_t * p=(uint64_t *)(flow_var+m_flow_offset); - *p=*p+1; - if (*p>m_max_val) { - *p=m_min_val; + uint64_t *p = (uint64_t *)(flow_var + m_flow_offset); + if (*p == m_max_val) { + *p = m_min_val; + } else { + *p = *p + 1; } } inline void run_dec(uint8_t * flow_var) { - uint64_t * p=(uint64_t *)(flow_var+m_flow_offset); - *p=*p-1; - if (*p<m_min_val) { - *p=m_max_val; + uint64_t *p = (uint64_t *)(flow_var + m_flow_offset); + if (*p == m_min_val) { + *p = m_max_val; + } else { + *p = *p - 1; } } |