Skip to content

Commit 7ed6b39

Browse files
committed
Fixed coverity issues in acl_mem.cpp: Constant expression result
Changed a lot of the && to || because CL_MEM_OBJECT_IMAGE1D, CL_MEM_OBJECT_IMAGE1D_ARRAY, and CL_MEM_OBJECT_IMAGE1D_BUFFER are all defined as strictly different values respectively 0x10F4, 0x10F5, and 0x10F6. Therefore that section of the statement would never be accessed. Logically, if the object is a 1D image, no matter which one it is, the slice pitch will not have a height and would just be equal to the row pitch, therefore I think logical OR makes sense. (line 2957) ((map_flags & CL_MAP_READ) & (map_flags & CL_MAP_WRITE_INVALIDATE_REGION)), both will only return the common bit between map_flags and the 2nd value, CL_MAP_READ being 1 and CL_MAP_WRITE_INVALIDATE_REGION being 4, but there are no common bits between 1 and 4, therefore this statement will always be false. From the comments, I believe that this block takes care of the state where map_flags contains both one of CL_MAP_READ or CL_MAP_WRITE and CL_MAP_WRITE_INVALIDATE_REGION. and therefore should replace the middle & to &&.
1 parent cd2164e commit 7ed6b39

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/acl_mem.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,8 +2060,8 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadImageIntelFPGA(
20602060
image->fields.image_objs.image_desc->image_width * src_element_size;
20612061
}
20622062

2063-
if (image->mem_object_type == CL_MEM_OBJECT_IMAGE1D &&
2064-
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY &&
2063+
if (image->mem_object_type == CL_MEM_OBJECT_IMAGE1D ||
2064+
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY ||
20652065
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
20662066
tmp_slice_pitch = tmp_row_pitch;
20672067
} else {
@@ -2161,8 +2161,8 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteImageIntelFPGA(
21612161
image->fields.image_objs.image_desc->image_width * dst_element_size;
21622162
}
21632163

2164-
if (image->mem_object_type == CL_MEM_OBJECT_IMAGE1D &&
2165-
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY &&
2164+
if (image->mem_object_type == CL_MEM_OBJECT_IMAGE1D ||
2165+
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY ||
21662166
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
21672167
tmp_slice_pitch = tmp_row_pitch;
21682168
} else {
@@ -2351,8 +2351,8 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueFillImageIntelFPGA(
23512351
region[0] *
23522352
dst_element_size; // Width of each row of the memory that ptr points to.
23532353

2354-
if (image->mem_object_type == CL_MEM_OBJECT_IMAGE1D &&
2355-
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY &&
2354+
if (image->mem_object_type == CL_MEM_OBJECT_IMAGE1D ||
2355+
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY ||
23562356
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
23572357
tmp_slice_pitch = tmp_row_pitch;
23582358
} else {
@@ -2554,8 +2554,8 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyImageToBufferIntelFPGA(
25542554

25552555
tmp_row_pitch =
25562556
src_image->fields.image_objs.image_desc->image_width * src_element_size;
2557-
if (src_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D &&
2558-
src_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY &&
2557+
if (src_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D ||
2558+
src_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY ||
25592559
src_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
25602560
tmp_slice_pitch = tmp_row_pitch;
25612561
} else {
@@ -2649,8 +2649,8 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyBufferToImageIntelFPGA(
26492649

26502650
tmp_row_pitch =
26512651
dst_image->fields.image_objs.image_desc->image_width * dst_element_size;
2652-
if (dst_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D &&
2653-
dst_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY &&
2652+
if (dst_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D ||
2653+
dst_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY ||
26542654
dst_image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
26552655
tmp_slice_pitch = tmp_row_pitch;
26562656
} else {
@@ -2954,9 +2954,9 @@ CL_API_ENTRY void *CL_API_CALL clEnqueueMapBufferIntelFPGA(
29542954
~(CL_MAP_READ | CL_MAP_WRITE | CL_MAP_WRITE_INVALIDATE_REGION)) {
29552955
BAIL_INFO(CL_INVALID_VALUE, context, "Invalid or unsupported flags");
29562956
}
2957-
if (((map_flags & CL_MAP_READ) &
2957+
if (((map_flags & CL_MAP_READ) &&
29582958
(map_flags & CL_MAP_WRITE_INVALIDATE_REGION)) ||
2959-
((map_flags & CL_MAP_WRITE) &
2959+
((map_flags & CL_MAP_WRITE) &&
29602960
(map_flags & CL_MAP_WRITE_INVALIDATE_REGION))) {
29612961
BAIL_INFO(
29622962
CL_INVALID_VALUE, context,

0 commit comments

Comments
 (0)