Fixed coverity issues in acl_program.cpp by haoxian2 · Pull Request #228 · intel/fpga-runtime-for-opencl (original) (raw)

Fixed coverity in acl_program.cpp: Dead default in switch (DEADCODE)

(line 256) Default branch never reached since switch (pass) only has 0 and 1 as values because pass is defined in a for-loop (line 225) as < 2.

Fixed coverity in acl_program.cpp: Dereference before null check (REVERSE_INULL)

(line 145) Program is already dereferenced in the for-loop above to check program->num_devices, so the check would also pass.

Fixed coverity in acl_program.cpp: Use after free (USE_AFTER_FREE)

(line 1834) Coverity complains that you should not print the pointer address value if it has already been freed. Since we are not accessing what's in the pointer itself, it is safe to query about pointer address value. Therefore, instead of passing the pointer as the argument, a dereferenced pointer to that pointer is passed as an argument instead.