7575#define UCP_MLX_PREFIX "mlx"
7676#define UCP_MLX_DEFAULT_PORT "1"
7777
78- #define UCP_IS_RESOURCE_MLX_DEFAULT_PORT (_dev_name , _dev_name_suffix ) \
79- ((!strncmp(_dev_name, UCP_MLX_PREFIX, strlen(UCP_MLX_PREFIX))) && \
80- (!strcmp(_dev_name_suffix, UCP_MLX_DEFAULT_PORT)))
81-
8278typedef enum ucp_transports_list_search_result {
8379 UCP_TRANSPORTS_LIST_SEARCH_RESULT_PRIMARY = UCS_BIT (0 ),
8480 UCP_TRANSPORTS_LIST_SEARCH_RESULT_AUX_IN_MAIN = UCS_BIT (1 ),
@@ -1029,8 +1025,8 @@ static uint64_t ucp_str_array_search_in_ranges(const char **array,
10291025 }
10301026
10311027 n = 0 ;
1032- if (sscanf (p , "[%lu-%lu]%n" , & range_start , & range_end , & n ) != 2 ||
1033- n == 0 || p [n ] != '\0' || range_start > range_end ) {
1028+ if (( sscanf (p , "[%lu-%lu]%n" , & range_start , & range_end , & n ) != 2 ) ||
1029+ ( n == 0 ) || ( p [n ] != '\0' ) || ( range_start > range_end ) ) {
10341030 continue ; /* Invalid range */
10351031 }
10361032
@@ -1095,6 +1091,13 @@ static const char *ucp_get_dev_name_suffix(const char *dev_name)
10951091 return colon + 1 ;
10961092}
10971093
1094+ static inline int
1095+ ucp_is_dev_mlx_default_port (const char * dev_name , const char * dev_name_suffix )
1096+ {
1097+ return (!strncmp (dev_name , UCP_MLX_PREFIX , strlen (UCP_MLX_PREFIX ))) &&
1098+ (!strcmp (dev_name_suffix , UCP_MLX_DEFAULT_PORT ));
1099+ }
1100+
10981101static int ucp_is_resource_in_device_list (const uct_tl_resource_desc_t * resource ,
10991102 const ucs_config_names_array_t * devices ,
11001103 uint64_t * dev_cfg_mask ,
@@ -1113,10 +1116,8 @@ static int ucp_is_resource_in_device_list(const uct_tl_resource_desc_t *resource
11131116
11141117 if (dev_type == UCT_DEVICE_TYPE_NET ) {
11151118 dev_name_suffix = ucp_get_dev_name_suffix (resource -> dev_name );
1116- ucs_assert (dev_name_suffix > resource -> dev_name &&
1117- dev_name_suffix <= resource -> dev_name + strlen (resource -> dev_name ));
11181119
1119- if (UCP_IS_RESOURCE_MLX_DEFAULT_PORT (resource -> dev_name , dev_name_suffix )) {
1120+ if (ucp_is_dev_mlx_default_port (resource -> dev_name , dev_name_suffix )) {
11201121 ucs_strncpy_zero (dev_name_base , resource -> dev_name ,
11211122 (size_t )(dev_name_suffix - resource -> dev_name ));
11221123
@@ -1132,8 +1133,8 @@ static int ucp_is_resource_in_device_list(const uct_tl_resource_desc_t *resource
11321133 }
11331134 }
11341135
1135- /* if the user's list is 'all', use all the available resources */
11361136 if (!mask ) {
1137+ /* if the user's list is 'all', use all the available resources */
11371138 mask = ucp_str_array_search ((const char * * )devices [dev_type ].names ,
11381139 devices [dev_type ].count , UCP_RSC_CONFIG_ALL ,
11391140 NULL );
0 commit comments