Skip to content

Commit

Permalink
Merge pull request #691 from bratpiorka/rrudnick_fix_hwloc_cov
Browse files Browse the repository at this point in the history
fix coverity issues in hwloc
  • Loading branch information
lukaszstolarczuk authored Aug 23, 2024
2 parents 19c67d1 + 2bfecdd commit 7b2aae5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ else()
set(HWLOC_ENABLE_TESTING OFF)
set(HWLOC_SKIP_LSTOPO ON)
set(HWLOC_SKIP_TOOLS ON)
set(HWLOC_PATCH
git
apply
${PROJECT_SOURCE_DIR}/cmake/fix_coverity_issues.patch
||
true)

message(
STATUS
Expand All @@ -137,7 +143,8 @@ else()
hwloc_targ
GIT_REPOSITORY ${UMF_HWLOC_REPO}
GIT_TAG ${UMF_HWLOC_TAG}
SOURCE_SUBDIR contrib/windows-cmake/ FIND_PACKAGE_ARGS)
PATCH_COMMAND ${HWLOC_PATCH} SOURCE_SUBDIR contrib/windows-cmake/
FIND_PACKAGE_ARGS)

FetchContent_GetProperties(hwloc_targ)
if(NOT hwloc_targ_POPULATED)
Expand All @@ -150,6 +157,13 @@ else()
${hwloc_targ_BINARY_DIR}/Release;${hwloc_targ_BINARY_DIR}/Debug)
else()
include(FetchContent)
set(HWLOC_PATCH
git
apply
${PROJECT_SOURCE_DIR}/cmake/fix_coverity_issues.patch
||
true)

message(
STATUS
"Will fetch hwloc from ${UMF_HWLOC_REPO} (tag: ${UMF_HWLOC_TAG})"
Expand All @@ -158,7 +172,8 @@ else()
FetchContent_Declare(
hwloc_targ
GIT_REPOSITORY ${UMF_HWLOC_REPO}
GIT_TAG ${UMF_HWLOC_TAG})
GIT_TAG ${UMF_HWLOC_TAG}
PATCH_COMMAND ${HWLOC_PATCH})

FetchContent_GetProperties(hwloc_targ)
if(NOT hwloc_targ_POPULATED)
Expand Down
14 changes: 14 additions & 0 deletions cmake/fix_coverity_issues.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/hwloc/topology-x86.c b/hwloc/topology-x86.c
index 7aabd168f..b01e44557 100644
--- a/hwloc/topology-x86.c
+++ b/hwloc/topology-x86.c
@@ -1375,6 +1375,9 @@ look_procs(struct hwloc_backend *backend, struct procinfo *infos, unsigned long
hwloc_bitmap_t set = NULL;
unsigned i;

+ if(!get_cpubind||!set_cpubind)
+ return -1;
+
if (!data->src_cpuiddump_path) {
orig_cpuset = hwloc_bitmap_alloc();
if (get_cpubind(topology, orig_cpuset, HWLOC_CPUBIND_STRICT)) {

0 comments on commit 7b2aae5

Please sign in to comment.