From e88adca2b022cd9c7e0ac87b5a92ac92f1c1c4aa Mon Sep 17 00:00:00 2001 From: "Yang, Hao Xiang" Date: Mon, 5 Dec 2022 11:32:02 -0800 Subject: [PATCH] Fixed coverity issue in acl_kernel_if.cpp: Type: Reliance on integer endianness (INCOMPATIBLE_CAST) In the three instances where this issue happens, the function acl_kernel_if_read_32b is used at the end of the scope to query about what's inside the acl_kernel_if* kern object. However, they don't do anything with the obtained information. I believe this read operation is performed to confirm that the acl_kernel_if* kern has been written properly. So if the read operation successed, then the write operation must have also succeeded as well. The functions employing acl_kernel_if_read_32b are used to return the segment offset. This segment offset is then used to perform another read/write, which return status would then be used for error checking. Therefore, the `acl_kernel_if_read_32b` function is redundant and can be removed from the aformentioned 3 instances. --- src/acl_kernel_if.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/acl_kernel_if.cpp b/src/acl_kernel_if.cpp index 347f7827..6c7e11db 100644 --- a/src/acl_kernel_if.cpp +++ b/src/acl_kernel_if.cpp @@ -453,8 +453,6 @@ static uintptr_t acl_kernel_cra_set_segment(acl_kernel_if *kern, acl_kernel_if_write_32b(kern, OFFSET_KERNEL_CRA_SEGMENT, (unsigned int)segment); kern->cur_segment = segment; - acl_kernel_if_read_32b(kern, OFFSET_KERNEL_CRA_SEGMENT, - (unsigned int *)&segment); } return segment_offset; @@ -470,8 +468,6 @@ static uintptr_t acl_kernel_cra_set_segment_rom(acl_kernel_if *kern, acl_kernel_if_write_32b(kern, OFFSET_KERNEL_CRA_SEGMENT, (unsigned int)segment); kern->cur_segment = segment; - acl_kernel_if_read_32b(kern, OFFSET_KERNEL_CRA_SEGMENT, - (unsigned int *)&segment); } return segment_offset; @@ -1613,8 +1609,6 @@ void acl_kernel_if_update_status(acl_kernel_if *kern) { acl_kernel_if_write_32b(kern, OFFSET_KERNEL_CRA_SEGMENT, (unsigned int)segment_pre_irq); kern->cur_segment = segment_pre_irq; - acl_kernel_if_read_32b(kern, OFFSET_KERNEL_CRA_SEGMENT, - (unsigned int *)&segment_pre_irq); } }