summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat
diff options
context:
space:
mode:
authorZane Shelley <zshelle@us.ibm.com>2017-02-07 12:23:55 -0600
committerZane C. Shelley <zshelle@us.ibm.com>2017-02-10 17:33:52 -0500
commit41103661c9b17f81fd9be971c476c657b4379275 (patch)
tree318f69601b81b20dec403bcbfff5b185efc0a43f /src/usr/diag/prdf/common/plat
parentfd704cf1b023c60aa8bc1ac428302e8d3f6c7358 (diff)
downloadtalos-hostboot-41103661c9b17f81fd9be971c476c657b4379275.tar.gz
talos-hostboot-41103661c9b17f81fd9be971c476c657b4379275.zip
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>
Diffstat (limited to 'src/usr/diag/prdf/common/plat')
-rwxr-xr-xsrc/usr/diag/prdf/common/plat/prdfTargetServices.C92
1 files changed, 37 insertions, 55 deletions
diff --git a/src/usr/diag/prdf/common/plat/prdfTargetServices.C b/src/usr/diag/prdf/common/plat/prdfTargetServices.C
index 1b5193328..4c466ad46 100755
--- a/src/usr/diag/prdf/common/plat/prdfTargetServices.C
+++ b/src/usr/diag/prdf/common/plat/prdfTargetServices.C
@@ -454,13 +454,12 @@ struct conn_t
};
-int32_t getAssociationType( TARGETING::TargetHandle_t i_target,
- TARGETING::TYPE i_connType,
- TARGETING::TargetService::ASSOCIATION_TYPE & o_type)
+TargetService::ASSOCIATION_TYPE getAssociationType( TargetHandle_t i_target,
+ TYPE i_connType )
{
#define PRDF_FUNC "[PlatServices::getAssociationType] "
- int32_t o_rc = SUCCESS;
+ PRDF_ASSERT( nullptr != i_target );
static conn_t lookups[] =
{
@@ -547,35 +546,23 @@ int32_t getAssociationType( TARGETING::TargetHandle_t i_target,
};
- do
- {
- if ( NULL == i_target )
- {
- PRDF_ERR( PRDF_FUNC "Given target is null" );
- o_rc = FAIL; break;
- }
-
- const size_t sz_lookups = sizeof(lookups) / sizeof(conn_t);
-
- TYPE type = getTargetType(i_target);
+ const size_t sz_lookups = sizeof(lookups) / sizeof(conn_t);
- conn_t match = { type, i_connType, TargetService::CHILD_BY_AFFINITY };
+ TYPE type = getTargetType(i_target);
- conn_t * it = std::lower_bound( lookups, lookups + sz_lookups, match );
+ conn_t match = { type, i_connType, TargetService::CHILD_BY_AFFINITY };
- if ( (it == lookups + sz_lookups) || // off the end
- (type != it->from) || (i_connType != it->to) ) // not equals
- {
- PRDF_ERR( PRDF_FUNC "Look-up failed: i_target=0x%08x i_connType=%d",
- getHuid(i_target), i_connType );
- o_rc = FAIL; break;
- }
-
- o_type = it->type;
+ conn_t * it = std::lower_bound( lookups, lookups + sz_lookups, match );
- } while (0);
+ if ( (it == lookups + sz_lookups) || // off the end
+ (type != it->from) || (i_connType != it->to) ) // not equals
+ {
+ PRDF_ERR( PRDF_FUNC "Look-up failed: i_target=0x%08x i_connType=%d",
+ getHuid(i_target), i_connType );
+ PRDF_ASSERT(false);
+ }
- return o_rc;
+ return it->type;
#undef PRDF_FUNC
}
@@ -633,11 +620,8 @@ TargetHandleList getConnected( TargetHandle_t i_target, TYPE i_connType )
break;
}
- TargetService::ASSOCIATION_TYPE assocType;
- int32_t l_rc = getAssociationType( i_target, i_connType, assocType );
- if ( SUCCESS != l_rc ) break;
-
- o_list = getConnAssoc( i_target, i_connType, assocType );
+ o_list = getConnAssoc( i_target, i_connType,
+ getAssociationType(i_target, i_connType) );
} while(0);
@@ -654,19 +638,18 @@ TargetHandle_t getConnectedParent( TargetHandle_t i_target, TYPE i_connType )
TargetHandle_t o_parent = NULL;
- do
+ // Get the association type, must be PARENT_BY_AFFINITY.
+ TargetService::ASSOCIATION_TYPE assocType = getAssociationType( i_target,
+ i_connType);
+ if ( TargetService::PARENT_BY_AFFINITY != assocType )
{
- TargetService::ASSOCIATION_TYPE assocType;
- int32_t l_rc = getAssociationType( i_target, i_connType, assocType );
- if ( SUCCESS != l_rc ) break;
-
- if ( TargetService::PARENT_BY_AFFINITY != assocType )
- {
- PRDF_ERR( PRDF_FUNC "Unsupported parent connection: i_target=0x%08x "
- "i_connType=%d", getHuid(i_target), i_connType );
- break;
- }
+ PRDF_ERR( PRDF_FUNC "Unsupported parent connection: i_target=0x%08x "
+ "i_connType=%d", getHuid(i_target), i_connType );
+ PRDF_ASSERT(false);
+ }
+ do
+ {
TargetHandleList list = getConnAssoc( i_target, i_connType, assocType );
if ( 1 != list.size() ) // Should be one and only one parent
{
@@ -695,19 +678,18 @@ TargetHandle_t getConnectedChild( TargetHandle_t i_target, TYPE i_connType,
TargetHandle_t o_child = NULL;
- do
+ // Get the association type, must be CHILD_BY_AFFINITY.
+ TargetService::ASSOCIATION_TYPE assocType = getAssociationType( i_target,
+ i_connType);
+ if ( TargetService::CHILD_BY_AFFINITY != assocType )
{
- TargetService::ASSOCIATION_TYPE assocType;
- int32_t l_rc = getAssociationType( i_target, i_connType, assocType );
- if ( SUCCESS != l_rc ) break;
-
- if ( TargetService::CHILD_BY_AFFINITY != assocType )
- {
- PRDF_ERR( PRDF_FUNC "Unsupported child connection: i_target=0x%08x "
- "i_connType=%d", getHuid(i_target), i_connType );
- break;
- }
+ PRDF_ERR( PRDF_FUNC "Unsupported child connection: i_target=0x%08x "
+ "i_connType=%d", getHuid(i_target), i_connType );
+ PRDF_ASSERT(false);
+ }
+ do
+ {
// Get the list.
TargetHandleList list = getConnAssoc( i_target, i_connType, assocType );
if ( list.empty() )
OpenPOWER on IntegriCloud