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/93173
Reviewed-by: Christian R Geddes <crgeddes@us.ibm.com>
Tested-by: Christian R Geddes <crgeddes@us.ibm.com>
  • Loading branch information
aamarin authored and crgeddes committed Mar 25, 2020
1 parent 4991558 commit f1c57dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 58 deletions.
51 changes: 4 additions & 47 deletions src/import/generic/memory/lib/data_engine/data_engine_utils.H
Expand Up @@ -245,33 +245,12 @@ inline fapi2::ReturnCode update_data(const std::shared_ptr<efd::base_decoder>& i
const auto l_dimm_index = i_efd_data->get_rank() / mss::MAX_RANK_PER_DIMM;
const auto l_dimm_rank = i_efd_data->get_rank() % mss::MAX_RANK_PER_DIMM;

FAPI_ASSERT( l_dimm_index < X,
fapi2::MSS_OUT_OF_BOUNDS_INDEXING()
.set_INDEX(l_dimm_index)
.set_LIST_SIZE(X)
.set_FUNCTION(i_ffdc_code)
.set_TARGET(l_ocmb),
"Dimm index (%d) was larger than max (%d) on %s",
l_dimm_index,
X,
mss::spd::c_str(l_ocmb) );

FAPI_ASSERT( l_dimm_rank < Y,
fapi2::MSS_OUT_OF_BOUNDS_INDEXING()
.set_INDEX(l_dimm_rank)
.set_LIST_SIZE(X)
.set_FUNCTION(i_ffdc_code)
.set_TARGET(l_ocmb),
"Rank index (%d) was larger than max (%d) on %s",
l_dimm_rank,
Y,
mss::spd::c_str(l_ocmb) );
FAPI_TRY( check::index_within_bounds(l_ocmb, l_dimm_index, X, i_ffdc_code) );
FAPI_TRY( check::index_within_bounds(l_ocmb, l_dimm_rank, Y, i_ffdc_code) );

FAPI_DBG("Updating data[%d][%d] with %d for %s", l_dimm_index, l_dimm_rank, i_setting, spd::c_str(l_ocmb));
o_data[l_dimm_index][l_dimm_rank] = i_setting;

return fapi2::FAPI2_RC_SUCCESS;

fapi_try_exit:
return fapi2::current_err;
}
Expand Down Expand Up @@ -299,22 +278,11 @@ inline fapi2::ReturnCode update_data( const spd::facade& i_spd_data,
const auto l_dimm = i_spd_data.get_dimm_target();
const size_t l_dimm_index = mss::index(l_dimm);

FAPI_ASSERT( l_dimm_index < X,
fapi2::MSS_OUT_OF_BOUNDS_INDEXING()
.set_INDEX(l_dimm_index)
.set_LIST_SIZE(X)
.set_FUNCTION(i_ffdc_code)
.set_TARGET(l_dimm),
"Dimm index (%d) was larger than max (%d) on %s",
l_dimm_index,
X,
mss::spd::c_str(l_dimm) );
FAPI_TRY( check::index_within_bounds(l_dimm, l_dimm_index, X, i_ffdc_code) );

FAPI_DBG("Updating data[%d] with %d for %s", l_dimm_index, i_setting, spd::c_str(l_dimm));
o_data[l_dimm_index] = i_setting;

return fapi2::FAPI2_RC_SUCCESS;

fapi_try_exit:
return fapi2::current_err;
}
Expand Down Expand Up @@ -342,22 +310,11 @@ inline fapi2::ReturnCode update_data( const fapi2::Target<T>& i_target,
{
const size_t l_dimm_index = mss::index(i_target);

FAPI_ASSERT( l_dimm_index < X,
fapi2::MSS_OUT_OF_BOUNDS_INDEXING()
.set_INDEX(l_dimm_index)
.set_LIST_SIZE(X)
.set_FUNCTION(i_ffdc_code)
.set_TARGET(i_target),
"Dimm index (%d) was larger than max (%d) on %s",
l_dimm_index,
X,
mss::spd::c_str(i_target) );
FAPI_TRY( check::index_within_bounds(i_target, l_dimm_index, X, i_ffdc_code) );

FAPI_DBG("Updating data[%d] with %d for %s", l_dimm_index, i_setting, spd::c_str(i_target));
o_data[l_dimm_index] = i_setting;

return fapi2::FAPI2_RC_SUCCESS;

fapi_try_exit:
return fapi2::current_err;
}
Expand Down
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 f1c57dd

Please sign in to comment.