Skip to content
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

cppcheck - various fixes #8622

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/runtime_src/core/common/api/hw_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ class hw_queue : public xrt::detail::pimpl<hw_queue_impl>
hw_queue() = default;

// Construct from hwctx
explicit
hw_queue(const xrt::hw_context& hwctx);

// Legacy construction for internal support of command execution
// that is not tied to kernel execution, .e.g for copy_bo_with_kdma
XRT_CORE_COMMON_EXPORT
explicit
hw_queue(const xrt_core::device* device);

// Start a command and manage its execution by monitoring
Expand Down
13 changes: 11 additions & 2 deletions src/runtime_src/core/common/api/xrt_bo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ class bo_impl
return device.get_hwctx_handle();
}

void*
get_hbuf_or_error() const
{
if (auto hbuf = get_hbuf())
return hbuf;

throw xrt_core::error("buffer is not mapped");
}

export_handle
export_buffer() const
{
Expand All @@ -338,7 +347,7 @@ class bo_impl
{
if (sz + seek > size)
throw xrt_core::error(-EINVAL,"attempting to write past buffer size");
auto hbuf = static_cast<char*>(get_hbuf()) + seek;
auto hbuf = static_cast<char*>(get_hbuf_or_error()) + seek;
std::memcpy(hbuf, src, sz);
}

Expand All @@ -347,7 +356,7 @@ class bo_impl
{
if (sz + skip > size)
throw xrt_core::error(-EINVAL,"attempting to read past buffer size");
auto hbuf = static_cast<char*>(get_hbuf()) + skip;
auto hbuf = static_cast<char*>(get_hbuf_or_error()) + skip;
std::memcpy(dst, hbuf, sz);
}

Expand Down
3 changes: 1 addition & 2 deletions src/runtime_src/core/common/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,9 @@ update_cu_info()
// It assumes that m_xclbin is the single xclbin and that
// there is only one default slot with number 0.
auto ip_layout = get_axlf_section<const ::ip_layout*>(IP_LAYOUT);
auto& cu2idx = m_cu2idx[0u]; // default slot 0
if (ip_layout != nullptr) {
m_cus = xclbin::get_cus(ip_layout);
cu2idx = xclbin::get_cu_indices(ip_layout);
m_cu2idx[0u] = xclbin::get_cu_indices(ip_layout); // default slot 0
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/runtime_src/core/common/ishim.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct ishim
class not_supported_error : public xrt_core::error
{
public:
explicit
not_supported_error(const std::string& msg)
: xrt_core::error{std::errc::not_supported, msg}
{}
Expand Down Expand Up @@ -253,6 +254,7 @@ template <typename DeviceType>
struct shim : public DeviceType
{
template <typename ...Args>
explicit
shim(Args&&... args)
: DeviceType(std::forward<Args>(args)...)
{}
Expand Down Expand Up @@ -410,6 +412,7 @@ template <typename DeviceType>
struct noshim : public DeviceType
{
template <typename ...Args>
explicit
noshim(Args&&... args)
: DeviceType(std::forward<Args>(args)...)
{}
Expand Down
Loading
Loading