@@ -151,6 +151,18 @@ hwloc_calc_get_obj_inside_sets_by_depth(struct hwloc_calc_location_context_s *lc
151
151
return NULL ;
152
152
}
153
153
154
+ /* return the length of the type/depth prefix
155
+ * 0 if not found or invalid.
156
+ */
157
+ static __hwloc_inline size_t
158
+ hwloc_calc_parse_level_size (const char * string )
159
+ {
160
+ /* type/depth prefix ends with either '.' (for child), "=" (for name of osdev),
161
+ * ':' (for index).
162
+ */
163
+ return strcspn (string , ":=." );
164
+ }
165
+
154
166
static __hwloc_inline int
155
167
hwloc_calc_parse_level (struct hwloc_calc_location_context_s * lcontext ,
156
168
hwloc_topology_t topology ,
@@ -328,7 +340,7 @@ hwloc_calc_append_object_range(struct hwloc_calc_location_context_s *lcontext,
328
340
/* parse the next string before calling ourself recursively */
329
341
size_t typelen ;
330
342
const char * nextstring = dot + 1 ;
331
- typelen = strspn (nextstring , "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" );
343
+ typelen = hwloc_calc_parse_level_size (nextstring );
332
344
if (!typelen || nextstring [typelen ] != ':' ) {
333
345
if (verbose >= 0 )
334
346
fprintf (stderr , "hierarchical sublocation %s contains types not followed by colon and index range\n" , nextstring );
@@ -592,6 +604,14 @@ hwloc_calc_process_location(struct hwloc_calc_location_context_s *lcontext,
592
604
hwloc_obj_t obj = NULL ;
593
605
594
606
if (* sep == ':' || * sep == '[' ) {
607
+ if (level .type == HWLOC_OBJ_PCI_DEVICE ) {
608
+ /* FIXME: temporary hack because typelen includes pci and osdev filters
609
+ * but only osdev types are handled in hwloc_calc_parse_level()
610
+ */
611
+ const char * bracket = strchr (arg , '[' );
612
+ if (bracket && bracket - sep < 0 )
613
+ sep = bracket ;
614
+ }
595
615
return hwloc_calc_append_iodev_by_index (lcontext , level .type , level .depth , sep , cbfunc , cbdata );
596
616
597
617
} else if (* sep == '=' && level .type == HWLOC_OBJ_PCI_DEVICE ) {
@@ -696,7 +716,7 @@ hwloc_calc_process_location_as_set(struct hwloc_calc_location_context_s *lcontex
696
716
mode , verbose );
697
717
698
718
/* try to match a type/depth followed by a special character */
699
- typelen = strspn (arg , "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" );
719
+ typelen = hwloc_calc_parse_level_size (arg );
700
720
if (typelen && (arg [typelen ] == ':' || arg [typelen ] == '=' || arg [typelen ] == '[' )) {
701
721
/* process type/depth */
702
722
struct hwloc_calc_process_location_set_cbdata_s cbdata ;
0 commit comments