summaryrefslogtreecommitdiffstats
path: root/import/hwpf/fapi2/include/buffer.H
diff options
context:
space:
mode:
authorBrian Silver <bsilver@us.ibm.com>2015-08-27 15:31:03 -0500
committerJoshua Hunsberger <jahunsbe@us.ibm.com>2017-10-23 15:51:43 -0500
commit2cb1dee70c617d460e0f0c9bde48a879d648b8dc (patch)
tree120c30274f4cf665b602c0293a111913b45d9848 /import/hwpf/fapi2/include/buffer.H
parent7dfe4af80afe72894a244193489dcdf7389ec7cf (diff)
downloadtalos-hcode-2cb1dee70c617d460e0f0c9bde48a879d648b8dc.tar.gz
talos-hcode-2cb1dee70c617d460e0f0c9bde48a879d648b8dc.zip
Fixed overflow problem in buffers
Change-Id: Idb3349052373cedaa8955b530a00dd7a25e72122 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/20182 Tested-by: Jenkins Server Reviewed-by: Matt K. Light <mklight@us.ibm.com> Reviewed-by: WILLIAM G. HOFFA <wghoffa@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Diffstat (limited to 'import/hwpf/fapi2/include/buffer.H')
-rw-r--r--import/hwpf/fapi2/include/buffer.H80
1 files changed, 40 insertions, 40 deletions
diff --git a/import/hwpf/fapi2/include/buffer.H b/import/hwpf/fapi2/include/buffer.H
index 6ee0f102..b7bd96c2 100644
--- a/import/hwpf/fapi2/include/buffer.H
+++ b/import/hwpf/fapi2/include/buffer.H
@@ -57,13 +57,13 @@ class buffer
~buffer(void) = default;
- #if !defined(DOXYGEN) && defined(FAPI2_DEBUG)
+#if !defined(DOXYGEN) && defined(FAPI2_DEBUG)
/// @brief Print the contents of the buffer to stdout
inline void print(void) const
{
TT::print(iv_data);
}
- #endif
+#endif
///
/// @brief Get the contents of the buffer
@@ -78,7 +78,7 @@ class buffer
/// @brief Get the contents of the buffer
/// @return The contents of the buffer
///
- inline operator T&()
+ inline operator T& ()
{
return iv_data;
}
@@ -124,7 +124,7 @@ class buffer
static const bits_type bits_in_value = parameterTraits<OT>::bit_length();
const bits_type bit_length = TT::bit_length(iv_data);
- if (i_offset + bits_in_value >= bit_length)
+ if (i_offset + bits_in_value > bit_length)
{
return FAPI2_RC_OVERFLOW;
}
@@ -178,7 +178,7 @@ class buffer
/// @note Example: fapi2::buffer<uint64_t>().setBit<3>();
///
template< bits_type B, bits_type C = 1 >
- inline buffer& setBit(void)
+ inline buffer & setBit(void)
{
static_assert((B >= 0) &&
((B + C - 1) < TT::bits_per_unit()), "failed range check");
@@ -222,10 +222,10 @@ class buffer
/// the case we can add a function parameter version.
///
template< bits_type B, bits_type C = 1>
- inline buffer& clearBit(void)
+ inline buffer & clearBit(void)
{
static_assert((B >= 0) &&
- ((B + C - 1)< TT::bits_per_unit()), "failed range check");
+ ((B + C - 1) < TT::bits_per_unit()), "failed range check");
iv_data &= buffer<T>().setBit<B, C>().invert();
return *this;
@@ -268,10 +268,10 @@ class buffer
/// the case we can add a function parameter version.
///
template< bits_type B, bits_type C = 1 >
- inline buffer& writeBit(const bool i_value)
+ inline buffer & writeBit(const bool i_value)
{
static_assert((B >= 0) &&
- ((B + C - 1)< TT::bits_per_unit()), "failed range check");
+ ((B + C - 1) < TT::bits_per_unit()), "failed range check");
(i_value == 0) ? clearBit<B, C>() : setBit<B, C>();
return *this;
@@ -288,7 +288,7 @@ class buffer
/// the case we can add a function parameter version.
///
template< bits_type B, bits_type C = 1 >
- inline buffer& flipBit(void)
+ inline buffer & flipBit(void)
{
static_assert((B >= 0) &&
((B + C - 1) < TT::bits_per_unit()), "failed range check");
@@ -365,86 +365,86 @@ class buffer
///
/// @brief operator>>()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator>>(bits_type i_shiftnum);
- #endif
+#endif
///
/// @brief operator<<()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator<<(bits_type i_shiftnum);
- #endif
+#endif
///
/// @brief operator+()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator+(const T& rhs);
- #endif
+#endif
///
/// @brief operator+=()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator+=(const T& rhs);
- #endif
+#endif
///
/// @brief operator|=()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator|=(const T& rhs);
- #endif
+#endif
///
/// @brief operator&=()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator&=(const T& rhs);
- #endif
+#endif
///
/// @brief operator|()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator|(const T& rhs);
- #endif
+#endif
///
/// @brief operator&()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator&(const T& rhs);
- #endif
+#endif
///
/// @brief operator^=()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator^=(const T& rhs);
- #endif
+#endif
///
/// @brief operator~()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline buffer<T>& operator~(const T& rhs) const;
- #endif
+#endif
///
/// @brief operator==()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline bool operator==(const T& rhs) const;
- #endif
+#endif
///
/// @brief operator!=()
///
- #ifdef DOXYGEN
+#ifdef DOXYGEN
inline bool operator!=(const T& rhs) const;
- #endif
+#endif
///
/// @brief Copy part of a OT into the DataBuffer
@@ -457,7 +457,7 @@ class buffer
/// @return buffer& Useful for method chaining
///
template<bits_type TS, bits_type L, bits_type SS = 0, typename OT>
- inline buffer& insert(const OT i_datain)
+ inline buffer & insert(const OT i_datain)
{
const bits_type target_length = parameterTraits<T>::bit_length();
const bits_type source_length = parameterTraits<OT>::bit_length();
@@ -598,7 +598,7 @@ class buffer
static_assert((TS + L) <= parameterTraits<T>::bit_length(),
"InsertFromRight(): (Target Start + Len) is out of bounds");
- this->insert<TS, L, parameterTraits<OT>::bit_length() - L>(i_datain);
+ this->insert < TS, L, parameterTraits<OT>::bit_length() - L > (i_datain);
return *this;
}
@@ -650,7 +650,7 @@ class buffer
/// @return const buffer& Useful for method chaining
///
template<bits_type SS, bits_type L, bits_type TS = 0, typename OT>
- inline const buffer& extract(OT& o_out) const
+ inline const buffer & extract(OT& o_out) const
{
// Extraction is just an insert into o_out
@@ -670,7 +670,7 @@ class buffer
/// @return buffer& Useful for method chaining
///
template<bits_type SS, bits_type L, bits_type TS = 0, typename OT>
- inline buffer& extract(OT& o_out)
+ inline buffer & extract(OT& o_out)
{
// Extraction is just an insert into o_out
@@ -718,7 +718,7 @@ class buffer
template<bits_type SS, bits_type L, typename OT>
inline const buffer& extractToRight(OT& o_out) const
{
- extract<SS, L, parameterTraits<OT>::bit_length() - L>(o_out);
+ extract < SS, L, parameterTraits<OT>::bit_length() - L > (o_out);
return *this;
}
@@ -733,7 +733,7 @@ class buffer
template<bits_type SS, bits_type L, typename OT>
inline buffer& extractToRight(OT& o_out)
{
- extract<SS, L, parameterTraits<OT>::bit_length() - L>(o_out);
+ extract < SS, L, parameterTraits<OT>::bit_length() - L > (o_out);
return *this;
}
OpenPOWER on IntegriCloud