Skip to content

Commit 4110366

Browse files
committed
PRD: Cleaned error handling for getAssociationType()
The function now immediately asserts if the association type lookup fails. Change-Id: I3dbabdcc05af7c914c77666597f6ef07768d2391 RTC: 168856 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36050 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/36077 Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
1 parent fd704cf commit 4110366

File tree

1 file changed

+37
-55
lines changed

1 file changed

+37
-55
lines changed

src/usr/diag/prdf/common/plat/prdfTargetServices.C

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,12 @@ struct conn_t
454454

455455
};
456456

457-
int32_t getAssociationType( TARGETING::TargetHandle_t i_target,
458-
TARGETING::TYPE i_connType,
459-
TARGETING::TargetService::ASSOCIATION_TYPE & o_type)
457+
TargetService::ASSOCIATION_TYPE getAssociationType( TargetHandle_t i_target,
458+
TYPE i_connType )
460459
{
461460
#define PRDF_FUNC "[PlatServices::getAssociationType] "
462461

463-
int32_t o_rc = SUCCESS;
462+
PRDF_ASSERT( nullptr != i_target );
464463

465464
static conn_t lookups[] =
466465
{
@@ -547,35 +546,23 @@ int32_t getAssociationType( TARGETING::TargetHandle_t i_target,
547546

548547
};
549548

550-
do
551-
{
552-
if ( NULL == i_target )
553-
{
554-
PRDF_ERR( PRDF_FUNC "Given target is null" );
555-
o_rc = FAIL; break;
556-
}
557-
558-
const size_t sz_lookups = sizeof(lookups) / sizeof(conn_t);
559-
560-
TYPE type = getTargetType(i_target);
549+
const size_t sz_lookups = sizeof(lookups) / sizeof(conn_t);
561550

562-
conn_t match = { type, i_connType, TargetService::CHILD_BY_AFFINITY };
551+
TYPE type = getTargetType(i_target);
563552

564-
conn_t * it = std::lower_bound( lookups, lookups + sz_lookups, match );
553+
conn_t match = { type, i_connType, TargetService::CHILD_BY_AFFINITY };
565554

566-
if ( (it == lookups + sz_lookups) || // off the end
567-
(type != it->from) || (i_connType != it->to) ) // not equals
568-
{
569-
PRDF_ERR( PRDF_FUNC "Look-up failed: i_target=0x%08x i_connType=%d",
570-
getHuid(i_target), i_connType );
571-
o_rc = FAIL; break;
572-
}
573-
574-
o_type = it->type;
555+
conn_t * it = std::lower_bound( lookups, lookups + sz_lookups, match );
575556

576-
} while (0);
557+
if ( (it == lookups + sz_lookups) || // off the end
558+
(type != it->from) || (i_connType != it->to) ) // not equals
559+
{
560+
PRDF_ERR( PRDF_FUNC "Look-up failed: i_target=0x%08x i_connType=%d",
561+
getHuid(i_target), i_connType );
562+
PRDF_ASSERT(false);
563+
}
577564

578-
return o_rc;
565+
return it->type;
579566

580567
#undef PRDF_FUNC
581568
}
@@ -633,11 +620,8 @@ TargetHandleList getConnected( TargetHandle_t i_target, TYPE i_connType )
633620
break;
634621
}
635622

636-
TargetService::ASSOCIATION_TYPE assocType;
637-
int32_t l_rc = getAssociationType( i_target, i_connType, assocType );
638-
if ( SUCCESS != l_rc ) break;
639-
640-
o_list = getConnAssoc( i_target, i_connType, assocType );
623+
o_list = getConnAssoc( i_target, i_connType,
624+
getAssociationType(i_target, i_connType) );
641625

642626
} while(0);
643627

@@ -654,19 +638,18 @@ TargetHandle_t getConnectedParent( TargetHandle_t i_target, TYPE i_connType )
654638

655639
TargetHandle_t o_parent = NULL;
656640

657-
do
641+
// Get the association type, must be PARENT_BY_AFFINITY.
642+
TargetService::ASSOCIATION_TYPE assocType = getAssociationType( i_target,
643+
i_connType);
644+
if ( TargetService::PARENT_BY_AFFINITY != assocType )
658645
{
659-
TargetService::ASSOCIATION_TYPE assocType;
660-
int32_t l_rc = getAssociationType( i_target, i_connType, assocType );
661-
if ( SUCCESS != l_rc ) break;
662-
663-
if ( TargetService::PARENT_BY_AFFINITY != assocType )
664-
{
665-
PRDF_ERR( PRDF_FUNC "Unsupported parent connection: i_target=0x%08x "
666-
"i_connType=%d", getHuid(i_target), i_connType );
667-
break;
668-
}
646+
PRDF_ERR( PRDF_FUNC "Unsupported parent connection: i_target=0x%08x "
647+
"i_connType=%d", getHuid(i_target), i_connType );
648+
PRDF_ASSERT(false);
649+
}
669650

651+
do
652+
{
670653
TargetHandleList list = getConnAssoc( i_target, i_connType, assocType );
671654
if ( 1 != list.size() ) // Should be one and only one parent
672655
{
@@ -695,19 +678,18 @@ TargetHandle_t getConnectedChild( TargetHandle_t i_target, TYPE i_connType,
695678

696679
TargetHandle_t o_child = NULL;
697680

698-
do
681+
// Get the association type, must be CHILD_BY_AFFINITY.
682+
TargetService::ASSOCIATION_TYPE assocType = getAssociationType( i_target,
683+
i_connType);
684+
if ( TargetService::CHILD_BY_AFFINITY != assocType )
699685
{
700-
TargetService::ASSOCIATION_TYPE assocType;
701-
int32_t l_rc = getAssociationType( i_target, i_connType, assocType );
702-
if ( SUCCESS != l_rc ) break;
703-
704-
if ( TargetService::CHILD_BY_AFFINITY != assocType )
705-
{
706-
PRDF_ERR( PRDF_FUNC "Unsupported child connection: i_target=0x%08x "
707-
"i_connType=%d", getHuid(i_target), i_connType );
708-
break;
709-
}
686+
PRDF_ERR( PRDF_FUNC "Unsupported child connection: i_target=0x%08x "
687+
"i_connType=%d", getHuid(i_target), i_connType );
688+
PRDF_ASSERT(false);
689+
}
710690

691+
do
692+
{
711693
// Get the list.
712694
TargetHandleList list = getConnAssoc( i_target, i_connType, assocType );
713695
if ( list.empty() )

0 commit comments

Comments
 (0)