Skip to content

Commit

Permalink
Update index_within_bounds() API
Browse files Browse the repository at this point in the history
Propagating new API for index checking for more
use to fit existing cases in source.

Change-Id: Iecd109b0c53089fccc413eedbd2202d6dfa46657
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/93135
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Louis Stermole <stermole@us.ibm.com>
Reviewed-by: Mark Pizzutillo <mark.pizzutillo@ibm.com>
Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Jennifer A Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/93172
Reviewed-by: RAJA DAS <rajadas2@in.ibm.com>
  • Loading branch information
aamarin authored and RAJA DAS committed Mar 26, 2020
1 parent ebcc0c0 commit 81d3ad9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/import/generic/memory/lib/utils/mss_field.H
Expand Up @@ -184,7 +184,7 @@ inline fapi2::ReturnCode get_field(const fapi2::Target<T>& i_target,
OT& o_value)
{
const size_t BYTE = F.get_byte(i_data);
FAPI_TRY(check::index_within_bounds(i_target, BYTE, i_data, i_ffdc_codes));
FAPI_TRY(check::index_within_bounds(i_target, BYTE, i_data.size(), i_ffdc_codes));

{
// clear out stale state
Expand Down Expand Up @@ -233,7 +233,7 @@ inline fapi2::ReturnCode set_field(const fapi2::Target<T>& i_target,
{
const size_t BYTE = F.get_byte(io_data);

FAPI_TRY(check::index_within_bounds(i_target, BYTE, io_data, i_ffdc_codes));
FAPI_TRY(check::index_within_bounds(i_target, BYTE, io_data.size(), i_ffdc_codes));
FAPI_TRY(check::invalid_type_conversion<uint8_t>(i_target, i_setting, i_ffdc_codes));

{
Expand Down
16 changes: 7 additions & 9 deletions src/import/generic/memory/lib/utils/mss_generic_check.H
Expand Up @@ -289,32 +289,30 @@ fapi_try_exit:
/// @brief Checks conditional passes and implements traces & exits if it fails
/// @tparam T fapi2 target type
/// @tparam IT index type
/// @tparam VT vector data type
/// @tparam ST size type
/// @tparam FFDC error callout code type
/// @param[in] i_target fapi2 target
/// @param[in] i_index desired vector index
/// @param[in] i_data vector data
/// @param[in] i_size size of the list we are comparing
/// @param[in] i_ffdc_codes FFDC code
/// @param[in] i_err_str error string - defaulted to ""
/// @return FAPI2_RC_SUCCESS iff okay
///
template< fapi2::TargetType T, typename IT, typename VT, typename FFDC >
template< fapi2::TargetType T, typename IT, typename ST, typename FFDC >
fapi2::ReturnCode index_within_bounds(const fapi2::Target<T>& i_target,
const IT i_index,
const std::vector<VT>& i_data,
const ST i_size,
const FFDC i_ffdc_codes,
const char* i_err_str = "")
{
const auto l_size = i_data.size();

FAPI_ASSERT( i_index < l_size,
FAPI_ASSERT( i_index < i_size,
fapi2::MSS_OUT_OF_BOUNDS_INDEXING()
.set_INDEX(i_index)
.set_LIST_SIZE(l_size)
.set_LIST_SIZE(i_size)
.set_FUNCTION(i_ffdc_codes)
.set_TARGET(i_target),
"%s. Out of bounds indexing (with %d) on a list of size %d for " TARGTIDFORMAT,
i_err_str, i_index, l_size, TARGTID );
i_err_str, i_index, i_size, TARGTID );

return fapi2::FAPI2_RC_SUCCESS;

Expand Down

0 comments on commit 81d3ad9

Please sign in to comment.