Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix DEADCODE Coverity issue for acl_context_test #253

Merged
merged 1 commit into from
Jan 30, 2023

Commits on Jan 30, 2023

  1. Fix DEADCODE Coverity issue

    A typo was causing much of the code to be seen as deadcode. A loop was not looping the correct number of times. This commit makes changes so that the correct number of loop iterations are done. However, with just this change, the test will fail since clCreateContextFromType returns CL_INVALID_DEVICE on the iteration with ienv = 1, apitype = 1, and i = 0. The reasoning for why this happens in the test is as follows:
    
    1. First, we set the environment to contain L_CONTEXT_OFFLINE_DEVICE_INTELFPGA=+a10_ref_small
    2. Then, we initialize our 5 accelerators that we use in the test. Since we have L_CONTEXT_OFFLINE_DEVICE_INTELFPGA=+a10_ref_small in our environment, this is equivalent to adding a 6th offline accelerator to our system.
    3. We then try to get our context by calling clCreateContextFromType. Note that we use CL_DEVICE_TYPE_ALL meaning we want all device types included in the context (i.e. doesn't matter if the devices are GPUs, CPUs, etc).
    4. Inside the clCreateContextFromType call, we get our desired set of devices by calling clGetDeviceIDs and pass them to l_finalize_context. The devices that we get from clGetDeviceIDs include the offline device we added through the environment variable.
    5. l_finalize_context calls l_init_context_with_devices with the same devices.
    6. Finally, l_init_context_with_devices correctly errors out since we have a combination of present and absent (offline) devices.
    
    So, this commit also changes the code within the for loop to account for the differences between each iteration.
    
    These Coverity issues are fixed with this commit:
    
    test/acl_context_test.cpp:1116:9:
      Type: Logically dead code (DEADCODE)
    
    test/acl_context_test.cpp:1111:9:
      cond_const: Condition "apitype", taking false branch. Now the value of "apitype" is equal to 0.
    test/acl_context_test.cpp:1117:13:
      const: At condition "apitype", the value of "apitype" must be equal to 0.
    test/acl_context_test.cpp:1116:9:
      dead_error_condition: The condition "apitype" cannot be true.
    test/acl_context_test.cpp:1116:9:
      dead_error_line: Execution cannot reach the expression "clCreateContextFromType(props, 4294967295UL, notify_me, this, &status)" inside this statement: "context = (apitype ? clCrea...".
    
    test/acl_context_test.cpp:1125:11:
      Type: Logically dead code (DEADCODE)
    
    test/acl_context_test.cpp:1103:9:
      assignment: Assigning: "fixed_val" = "0L".
    test/acl_context_test.cpp:1124:13:
      const: At condition "fixed_val != 0L", the value of "fixed_val" must be equal to 0.
    test/acl_context_test.cpp:1124:9:
      dead_error_condition: The condition "fixed_val != 0L" cannot be true.
    test/acl_context_test.cpp:1125:11:
      dead_error_line: Execution cannot reach this statement: "if (!envvals[ienv].valid) {...".
    IlanTruanovsky committed Jan 30, 2023
    Configuration menu
    Copy the full SHA
    1c82bd7 View commit details
    Browse the repository at this point in the history