From de4ae93cc155e9a6ffb78cddf3918a20fd926afd Mon Sep 17 00:00:00 2001 From: "Richard J. Knight" Date: Wed, 15 Jun 2016 12:48:35 -0500 Subject: Variable buffer issues when inserting OT variable buffer -Added check for integral_type for OT insert. This change forces the user to insert only integral types using the generic insert interface. Change-Id: Ic207f855afff5e80d6bb342f94873964a0f60d16 RTC:151788 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/25861 Tested-by: Jenkins Server Tested-by: PPE CI Reviewed-by: Soma Bhanutej Reviewed-by: Joachim Fenkes Tested-by: Hostboot CI Reviewed-by: Jennifer A. Stofer Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/25869 Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell --- src/import/hwpf/fapi2/include/variable_buffer.H | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/import') diff --git a/src/import/hwpf/fapi2/include/variable_buffer.H b/src/import/hwpf/fapi2/include/variable_buffer.H index 227ffc526..9bf9294e7 100644 --- a/src/import/hwpf/fapi2/include/variable_buffer.H +++ b/src/import/hwpf/fapi2/include/variable_buffer.H @@ -167,9 +167,9 @@ inline fapi2::ReturnCodes _insert(const unit_type* i_source, /// @note Variable buffers are not (presently) declared as std::bitset /// as bitsets' size is fixed at runtime. It is not clear if this is /// acceptable for variable_buffers at this time. -/// @note Variable buffers are implemented as a std::vecor of uint32_t +/// @note Variable buffers are implemented as a std::vector of uint32_t /// as this keeps simple compatibility with ecmdDataBuffers. Cronus (at -//least) need to interwork the two. +// least) needs to interwork the two. class variable_buffer { @@ -788,7 +788,7 @@ class variable_buffer /// @param[in] i_targetStart The position in this where the copy starts /// @param[in] i_len How many bits to copy /// @param[in] i_sourceStart The start positon in i_data, defaults to 0 - /// @return FAPI2_RC_SUCCESS on success, FAPi2_RC_OVERFLOW otherwise + /// @return FAPI2_RC_SUCCESS on success, FAPI2_RC_OVERFLOW otherwise /// template inline fapi2::ReturnCodes insert(const OT& i_data, @@ -796,6 +796,10 @@ class variable_buffer bits_type i_len = ~0, bits_type i_sourceStart = 0) { + // Compile time check to make sure OT is integral + static_assert( std::is_integral::value, + "Input must be an integral type" ); + // _insert likes 32-bit sources. So lets make our source 32 bits. uint32_t l_source = static_cast(i_data); bits_type l_sourceStart = i_sourceStart + @@ -1007,7 +1011,7 @@ inline fapi2::ReturnCodes variable_buffer::insert(const uint64_t& i_source, i_sourceStart, i_targetStart, i_len); } -// Insert another variable_bufer +// Insert another variable_buffer template<> inline fapi2::ReturnCodes variable_buffer::insert( const variable_buffer& i_data, -- cgit v1.2.1