@@ -454,13 +454,12 @@ struct conn_t
454
454
455
455
};
456
456
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 )
460
459
{
461
460
#define PRDF_FUNC "[PlatServices::getAssociationType] "
462
461
463
- int32_t o_rc = SUCCESS ;
462
+ PRDF_ASSERT ( nullptr != i_target ) ;
464
463
465
464
static conn_t lookups [] =
466
465
{
@@ -547,35 +546,23 @@ int32_t getAssociationType( TARGETING::TargetHandle_t i_target,
547
546
548
547
};
549
548
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 );
561
550
562
- conn_t match = { type , i_connType , TargetService :: CHILD_BY_AFFINITY } ;
551
+ TYPE type = getTargetType ( i_target ) ;
563
552
564
- conn_t * it = std :: lower_bound ( lookups , lookups + sz_lookups , match ) ;
553
+ conn_t match = { type , i_connType , TargetService :: CHILD_BY_AFFINITY } ;
565
554
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 );
575
556
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
+ }
577
564
578
- return o_rc ;
565
+ return it -> type ;
579
566
580
567
#undef PRDF_FUNC
581
568
}
@@ -633,11 +620,8 @@ TargetHandleList getConnected( TargetHandle_t i_target, TYPE i_connType )
633
620
break ;
634
621
}
635
622
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 ) );
641
625
642
626
} while (0 );
643
627
@@ -654,19 +638,18 @@ TargetHandle_t getConnectedParent( TargetHandle_t i_target, TYPE i_connType )
654
638
655
639
TargetHandle_t o_parent = NULL ;
656
640
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 )
658
645
{
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
+ }
669
650
651
+ do
652
+ {
670
653
TargetHandleList list = getConnAssoc ( i_target , i_connType , assocType );
671
654
if ( 1 != list .size () ) // Should be one and only one parent
672
655
{
@@ -695,19 +678,18 @@ TargetHandle_t getConnectedChild( TargetHandle_t i_target, TYPE i_connType,
695
678
696
679
TargetHandle_t o_child = NULL ;
697
680
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 )
699
685
{
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
+ }
710
690
691
+ do
692
+ {
711
693
// Get the list.
712
694
TargetHandleList list = getConnAssoc ( i_target , i_connType , assocType );
713
695
if ( list .empty () )
0 commit comments