Skip to content

fix coverity issues in hwloc #691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Loading