Skip to content

Commit

Permalink
PRD: added nullptr check to various functions in prdfTargetServices.C
Browse files Browse the repository at this point in the history
Functions should assert immediately if passed a nullptr target input.

Change-Id: I25b067bfd22515c1b6f35ecd0508eb29707ef8ca
RTC: 168856
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36051
Reviewed-by: Benjamin J. Weisenbeck <bweisenb@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Brian J. Stegmiller <bjs@us.ibm.com>
Reviewed-by: Zane C. Shelley <zshelle@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36078
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
  • Loading branch information
zane131 committed Feb 10, 2017
1 parent 4110366 commit 8ece861
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions src/usr/diag/prdf/common/plat/prdfTargetServices.C
Original file line number Diff line number Diff line change
Expand Up @@ -571,44 +571,32 @@ TargetService::ASSOCIATION_TYPE getAssociationType( TargetHandle_t i_target,
TargetHandleList getConnAssoc( TargetHandle_t i_target, TYPE i_connType,
TargetService::ASSOCIATION_TYPE i_assocType )
{
#define PRDF_FUNC "[PlatServices::getConnAssoc] "
PRDF_ASSERT( nullptr != i_target );

TargetHandleList o_list; // Default empty list

do
{
if ( NULL == i_target )
{
PRDF_ERR( PRDF_FUNC "Given target is null" );
break;
}

// Match any class, specified type, and functional.
PredicateCTM predType( CLASS_NA, i_connType );
PredicateIsFunctional predFunc;
PredicatePostfixExpr predAnd;
predAnd.push(&predType).push(&predFunc).And();

targetService().getAssociated( o_list, i_target, i_assocType,
TargetService::ALL, &predAnd );
// Match any class, specified type, and functional.
PredicateCTM predType( CLASS_NA, i_connType );
PredicateIsFunctional predFunc;
PredicatePostfixExpr predAnd;
predAnd.push(&predType).push(&predFunc).And();

// Sort by target position.
std::sort( o_list.begin(), o_list.end(),
[](TargetHandle_t a, TargetHandle_t b)
{ return getTargetPosition(a) < getTargetPosition(b); } );
targetService().getAssociated( o_list, i_target, i_assocType,
TargetService::ALL, &predAnd );

} while(0);
// Sort by target position.
std::sort( o_list.begin(), o_list.end(),
[](TargetHandle_t a, TargetHandle_t b)
{ return getTargetPosition(a) < getTargetPosition(b); } );

return o_list;

#undef PRDF_FUNC
}

//------------------------------------------------------------------------------

TargetHandleList getConnected( TargetHandle_t i_target, TYPE i_connType )
{
PRDF_ASSERT( NULL != i_target );
PRDF_ASSERT( nullptr != i_target );

TargetHandleList o_list; // Default empty list

Expand All @@ -634,7 +622,7 @@ TargetHandle_t getConnectedParent( TargetHandle_t i_target, TYPE i_connType )
{
#define PRDF_FUNC "[PlatServices::getConnectedParent] "

PRDF_ASSERT( NULL != i_target );
PRDF_ASSERT( nullptr != i_target );

TargetHandle_t o_parent = NULL;

Expand Down Expand Up @@ -674,9 +662,9 @@ TargetHandle_t getConnectedChild( TargetHandle_t i_target, TYPE i_connType,
{
#define PRDF_FUNC "[PlatServices::getConnectedChild] "

PRDF_ASSERT( NULL != i_target );
PRDF_ASSERT( nullptr != i_target );

TargetHandle_t o_child = NULL;
TargetHandle_t o_child = nullptr;

// Get the association type, must be CHILD_BY_AFFINITY.
TargetService::ASSOCIATION_TYPE assocType = getAssociationType( i_target,
Expand Down Expand Up @@ -1083,6 +1071,8 @@ uint32_t getTargetPosition( TARGETING::TargetHandle_t i_target )
{
#define PRDF_FUNC "[PlatServices::getTargetPosition] "

PRDF_ASSERT( nullptr != i_target );

uint32_t o_pos = INVALID_POSITION_BOUND;

CLASS l_class = getTargetClass( i_target );
Expand Down Expand Up @@ -1196,14 +1186,14 @@ uint32_t getMemChnl( TARGETING::TargetHandle_t i_memTarget )
{
#define PRDF_FUNC "[PlatServices::getMemChnl] "

PRDF_ASSERT( nullptr != i_memTarget );

uint32_t o_chnl = INVALID_POSITION_BOUND; // Intentially set to
// INVALID_POSITION_BOUND for call
// from getTargetPosition().

do
{
if ( NULL == i_memTarget ) break;

TargetHandle_t mcsTarget = getConnectedParent( i_memTarget, TYPE_MCS );
if ( NULL == mcsTarget )
{
Expand Down

0 comments on commit 8ece861

Please sign in to comment.