Skip to content

Fixed coverity issue in acl_device.cpp #225

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
Dec 8, 2022
Merged
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
21 changes: 15 additions & 6 deletions src/acl_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfoIntelFPGA(
RESULT_INT(0);
break;
case CL_DEVICE_GLOBAL_MEM_SIZE: {
auto gmem_id =
static_cast<size_t>(acl_get_default_device_global_memory(device->def));
auto gmem_id = acl_get_default_device_global_memory(device->def);
if (gmem_id < 0) {
RESULT_INT(0);
break;
}
cl_ulong size =
ACL_RANGE_SIZE(device->def.autodiscovery_def.global_mem_defs[gmem_id]
.get_usable_range());
Expand Down Expand Up @@ -255,8 +258,11 @@ CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfoIntelFPGA(
// However conformance_test_api min_max_constant_buffer_size
// expects to allocate two buffers of the size we say here.
// So be a shade conservative and cut it down by 4.
auto gmem_id =
static_cast<size_t>(acl_get_default_device_global_memory(device->def));
auto gmem_id = acl_get_default_device_global_memory(device->def);
if (gmem_id < 0) {
RESULT_INT(0);
break;
}
cl_ulong size =
ACL_RANGE_SIZE(device->def.autodiscovery_def.global_mem_defs[gmem_id]
.get_usable_range()) /
Expand All @@ -268,8 +274,11 @@ CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfoIntelFPGA(
RESULT_ULONG(size);
} break;
case CL_DEVICE_MAX_MEM_ALLOC_SIZE: {
auto gmem_id =
static_cast<size_t>(acl_get_default_device_global_memory(device->def));
auto gmem_id = acl_get_default_device_global_memory(device->def);
if (gmem_id < 0) {
RESULT_INT(0);
break;
}
cl_ulong size =
ACL_RANGE_SIZE(device->def.autodiscovery_def.global_mem_defs[gmem_id]
.get_usable_range());
Expand Down