Skip to content

acl_device_binary: fix missing assignment operator #207

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

Closed
wants to merge 1 commit into from
Closed

acl_device_binary: fix missing assignment operator #207

wants to merge 1 commit into from

Conversation

pcolberg
Copy link
Contributor

Class "acl_device_binary_t" owns resources that are freed in its
destructor but has no user-written assignment operator.

Signed-off-by: Peter Colberg [email protected]

@pcolberg pcolberg added the bug Something isn't working label Nov 22, 2022
@pcolberg pcolberg added this to the 2023.1 milestone Nov 22, 2022
@pcolberg pcolberg self-assigned this Nov 22, 2022
@pcolberg
Copy link
Contributor Author

--- cov-errors-33ef809.txt
+++ cov-errors-aebf33b.txt
@@ -1,79 +1,3 @@
-include/acl_device_binary.h:25:7:
-  Type: Missing assignment operator (MISSING_COPY_OR_ASSIGN)
-
-include/acl_device_binary.h:25:7:
-  missing_assign: Class "acl_device_binary_t" owns resources that are freed in its destructor but has no user-written assignment operator.
-include/acl_device_binary.h:25:7:
-  free_resource: The destructor frees member "m_binary_pkg".
-include/acl_device_binary.h:27:28:
-  freed_arg: "unload_content" frees parameter "this->m_binary_pkg".
-src/acl_device_binary.cpp:136:3:
-  path: Condition "this->m_binary_pkg", taking true branch.
-src/acl_device_binary.cpp:137:5:
-  freed_arg: "acl_pkg_close_file" frees parameter "this->m_binary_pkg".
-lib/pkg_editor/src/pkg_editor.c:1099:3:
-  path: Condition "!pkg", taking false branch.
-lib/pkg_editor/src/pkg_editor.c:1114:3:
-  path: Condition "pkg->writable", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1116:5:
-  path: Condition "data", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1121:3:
-  path: Condition "elf_end(pkg->elf)", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1122:5:
-  path: Condition "pkg->show_info", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1124:3:
-  path: Jumping back to the beginning of the loop.
-lib/pkg_editor/src/pkg_editor.c:1121:3:
-  path: Condition "elf_end(pkg->elf)", taking false branch.
-lib/pkg_editor/src/pkg_editor.c:1126:3:
-  path: Condition "pkg->fd != -1", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1127:5:
-  path: Condition "pkg->dirty", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1136:7:
-  path: Condition "status != 0", taking false branch.
-lib/pkg_editor/src/pkg_editor.c:1144:5:
-  path: Condition "status != 0", taking false branch.
-lib/pkg_editor/src/pkg_editor.c:1150:3:
-  freed_arg: "free" frees parameter "pkg".
-
-include/acl_device_binary.h:25:7:
-  Type: Missing copy constructor (MISSING_COPY_OR_ASSIGN)
-
-include/acl_device_binary.h:25:7:
-  missing_copy_ctor: Class "acl_device_binary_t" owns resources that are freed in its destructor but has no user-written copy constructor.
-include/acl_device_binary.h:25:7:
-  free_resource: The destructor frees member "m_binary_pkg".
-include/acl_device_binary.h:27:28:
-  freed_arg: "unload_content" frees parameter "this->m_binary_pkg".
-src/acl_device_binary.cpp:136:3:
-  path: Condition "this->m_binary_pkg", taking true branch.
-src/acl_device_binary.cpp:137:5:
-  freed_arg: "acl_pkg_close_file" frees parameter "this->m_binary_pkg".
-lib/pkg_editor/src/pkg_editor.c:1099:3:
-  path: Condition "!pkg", taking false branch.
-lib/pkg_editor/src/pkg_editor.c:1114:3:
-  path: Condition "pkg->writable", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1116:5:
-  path: Condition "data", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1121:3:
-  path: Condition "elf_end(pkg->elf)", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1122:5:
-  path: Condition "pkg->show_info", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1124:3:
-  path: Jumping back to the beginning of the loop.
-lib/pkg_editor/src/pkg_editor.c:1121:3:
-  path: Condition "elf_end(pkg->elf)", taking false branch.
-lib/pkg_editor/src/pkg_editor.c:1126:3:
-  path: Condition "pkg->fd != -1", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1127:5:
-  path: Condition "pkg->dirty", taking true branch.
-lib/pkg_editor/src/pkg_editor.c:1136:7:
-  path: Condition "status != 0", taking false branch.
-lib/pkg_editor/src/pkg_editor.c:1144:5:
-  path: Condition "status != 0", taking false branch.
-lib/pkg_editor/src/pkg_editor.c:1150:3:
-  freed_arg: "free" frees parameter "pkg".
-
 lib/CppUTest/include/CppUTest/CommandLineTestRunner.h:46:7:
   Type: Missing assignment operator (MISSING_COPY_OR_ASSIGN)

> Class "acl_device_binary_t" owns resources that are freed in its
> destructor but has no user-written assignment operator.

Signed-off-by: Peter Colberg <[email protected]>
@pcolberg pcolberg modified the milestones: 2023.1, 2023.2 Dec 23, 2022
@pcolberg
Copy link
Contributor Author

pcolberg commented Jan 6, 2023

Klocwork fails with false positive:

 163 (Local) /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/src/acl_device_program_info.cpp:57 LOCRET.RET (1:Critical) Analyze
Address of a local variable is returned via return statement expression '&acl_device_binary_t(dev_bin)'.
  * acl_device_program_info.cpp:57: Local address '&acl_device_binary_t(dev_bin)' is returned

acl_device_binary_t &
acl_device_program_info_t::add_split_binary(const std::string &hashed_name) {
assert(program->context->split_kernel);
auto &dev_bin = m_split_device_binaries[hashed_name];
dev_bin.set_dev_prog(this);
dev_bin.get_devdef().dev_prog = this;
return dev_bin;
}

@pcolberg
Copy link
Contributor Author

pcolberg commented Jan 9, 2023

Superseded by #236

@pcolberg pcolberg closed this Jan 9, 2023
@pcolberg pcolberg deleted the acl_device_binary branch January 9, 2023 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant