Skip to content

Commit cef7d4e

Browse files
committed
hwloc_obj_add_other_obj_sets: handle bitmap realloc errors
And document them in the API. Refs #578. Signed-off-by: Brice Goglin <[email protected]>
1 parent 03af5bc commit cef7d4e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

hwloc/topology.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,11 +2260,13 @@ fixup_sets(hwloc_obj_t obj)
22602260
int
22612261
hwloc_obj_add_other_obj_sets(hwloc_obj_t dst, hwloc_obj_t src)
22622262
{
2263-
#define ADD_OTHER_OBJ_SET(_dst, _src, _set) \
2264-
if ((_src)->_set) { \
2265-
if (!(_dst)->_set) \
2266-
(_dst)->_set = hwloc_bitmap_alloc(); \
2267-
hwloc_bitmap_or((_dst)->_set, (_dst)->_set, (_src)->_set); \
2263+
#define ADD_OTHER_OBJ_SET(_dst, _src, _set) \
2264+
if ((_src)->_set) { \
2265+
if (!(_dst)->_set) \
2266+
(_dst)->_set = hwloc_bitmap_alloc(); \
2267+
if (!(_dst)->_set \
2268+
|| hwloc_bitmap_or((_dst)->_set, (_dst)->_set, (_src)->_set) < 0) \
2269+
return -1; \
22682270
}
22692271
ADD_OTHER_OBJ_SET(dst, src, cpuset);
22702272
ADD_OTHER_OBJ_SET(dst, src, complete_cpuset);

include/hwloc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,6 +2565,9 @@ HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_group_object(hwloc_topology_t t
25652565
* This function is convenient between hwloc_topology_alloc_group_object()
25662566
* and hwloc_topology_insert_group_object(). It builds the sets of the new Group
25672567
* that will be inserted as a new intermediate parent of several objects.
2568+
*
2569+
* \return 0 on success.
2570+
* \return -1 with errno set to \c ENOMEM if some internal reallocation failed.
25682571
*/
25692572
HWLOC_DECLSPEC int hwloc_obj_add_other_obj_sets(hwloc_obj_t dst, hwloc_obj_t src);
25702573

0 commit comments

Comments
 (0)