diff options
author | Brian Silver <bsilver@us.ibm.com> | 2015-04-03 08:29:46 -0500 |
---|---|---|
committer | Patrick Williams <iawillia@us.ibm.com> | 2015-12-11 13:40:20 -0600 |
commit | e0c15c352f4ece425e29926aacd00cdf5a7661ff (patch) | |
tree | 2db0f974bf240390c91985fed95aafd926a5b348 /src/import/hwpf/fapi2/include/variable_buffer.H | |
parent | 550801e4e6120de1b2f2b0b41f9389074deda85e (diff) | |
download | talos-hostboot-e0c15c352f4ece425e29926aacd00cdf5a7661ff.tar.gz talos-hostboot-e0c15c352f4ece425e29926aacd00cdf5a7661ff.zip |
Make variable_buffer::set() overflow checking more precise
Fix toString() argument documentation
Change-Id: I321e59a89d52d8d1681515b76c796027d127078b
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/16848
Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Reviewed-by: PRACHI GUPTA <pragupta@us.ibm.com>
Reviewed-by: Brian Silver <bsilver@us.ibm.com>
Tested-by: Brian Silver <bsilver@us.ibm.com>
Diffstat (limited to 'src/import/hwpf/fapi2/include/variable_buffer.H')
-rw-r--r-- | src/import/hwpf/fapi2/include/variable_buffer.H | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/import/hwpf/fapi2/include/variable_buffer.H b/src/import/hwpf/fapi2/include/variable_buffer.H index f25f2b4d3..753434615 100644 --- a/src/import/hwpf/fapi2/include/variable_buffer.H +++ b/src/import/hwpf/fapi2/include/variable_buffer.H @@ -249,6 +249,31 @@ namespace fapi2 } /// + /// @brief Set an OT of data in buffer + /// @param[in] i_value sizeof(OT) bits of data + /// @param[in] i_offset Start OT (start word, for example) in buffer + /// - defaults to 0 (will by default write the left most element) + /// @return FAPI2_RC_SUCCESS on success, FAPI2_RC_OVERFLOW otherwise + /// @note This is is only available for integral types. To set a + /// variable_buffer into a variable_buffer, use insert() + /// + template< typename OT> + inline fapi2::ReturnCode set(OT i_value, const bits_type i_offset = 0) + { + // Do the variable_buffer specific check for overflow here. Then + // call the common set() + static const bits_type bits_in_value = parameterTraits<OT>::bit_length(); + const bits_type bit_length = bufferTraits<bits_container>::bit_length(iv_data); + + if ((i_offset + bits_in_value) >= this->iv_perceived_bit_length) + { + return FAPI2_RC_OVERFLOW; + } + + return buffer_base::set(i_value, i_offset); + } + + /// /// @brief Set a bit in the buffer /// @param[in] i_bit the bit number to set. /// @note 0 is left-most |