Skip to content

Fix problems in dpctl identified with Klockwork static code analysis #186

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 2 commits into from
Dec 3, 2020
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
6 changes: 5 additions & 1 deletion backends/source/dppl_sycl_context_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ bool DPPLContext_AreEq (__dppl_keep const DPPLSyclContextRef CtxRef1,

bool DPPLContext_IsHost (__dppl_keep const DPPLSyclContextRef CtxRef)
{
return unwrap(CtxRef)->is_host();
auto Ctx = unwrap(CtxRef);
if (Ctx) {
return Ctx->is_host();
}
return false;
}

void DPPLContext_Delete (__dppl_take DPPLSyclContextRef CtxRef)
Expand Down
7 changes: 6 additions & 1 deletion backends/source/dppl_sycl_platform_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ size_t DPPLPlatform_GetNumNonHostPlatforms ()

size_t DPPLPlatform_GetNumNonHostBackends ()
{
return get_set_of_non_hostbackends().size();
auto be_set = get_set_of_non_hostbackends();
Copy link
Contributor

@PokhodenkoSA PokhodenkoSA Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the problem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-void function does not return value

Copy link
Contributor

@PokhodenkoSA PokhodenkoSA Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return get_set_of_non_hostbackends().size(); does not return value? How it is possible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value should be returned, but at this point klocwork shows a warning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that klockwork requires this change, but if it fixes the warning then I am OK with this change.


if (be_set.empty())
return 0;

return be_set.size();
}

__dppl_give DPPLSyclBackendType *DPPLPlatform_GetListOfNonHostBackends ()
Expand Down