Skip to content

Commit

Permalink
Cov-* Misc Coverity fixes
Browse files Browse the repository at this point in the history
Mostly move related fixes, and explicit ctors.

Signed-off-by: Soren Soe <[email protected]>
  • Loading branch information
stsoe committed Nov 26, 2024
1 parent 81077cb commit c6951c9
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/api/xrt_bo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ bo::
size() const
{
return xdp::native::profiling_wrapper("xrt::bo::size", [this]{
return handle->get_size();
return handle ? handle->get_size() : 0;
}) ;
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/api/xrt_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3816,7 +3816,7 @@ add_callback(ert_cmd_state state,
// the key. Note that the callback cannot pass *this (xrt::run) as
// these objects are transient.
auto key = handle.get();
handle->add_callback([=](ert_cmd_state state) { fcn(key, state, data); });
handle->add_callback([fn = std::move(fcn), key, data](ert_cmd_state state) { fn(key, state, data); });
}

ert_packet*
Expand Down
14 changes: 7 additions & 7 deletions src/runtime_src/core/common/info_aie2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,34 +744,34 @@ get_aie_data(const xrt_core::device* device, const aie_tiles_info& info, aie_til
if (tiles_status.cols_filled == 0)
throw std::runtime_error("No open HW-Context\n");

std::vector<aie2::aie_tiles_status> aie_status;
std::vector<aie2::aie_tiles_status> aie_status_vec;

// Allocate an entry for each active column
// See core/xrt/src/runtime_src/core/common/design_notes.md entry 1
uint32_t cols_filled = tiles_status.cols_filled;
while (cols_filled) {
if (cols_filled & 0x1)
aie_status.emplace_back(info);
aie_status_vec.emplace_back(info);

cols_filled >>= 1;
}

switch (tile_type) {
case aie_tile_type::core:
parse_core_tile_buf(tiles_status.buf, info, aie_status);
parse_core_tile_buf(tiles_status.buf, info, aie_status_vec);
break;
case aie_tile_type::shim:
parse_shim_tile_buf(tiles_status.buf, info, aie_status);
parse_shim_tile_buf(tiles_status.buf, info, aie_status_vec);
break;
case aie_tile_type::mem:
parse_mem_tile_buf(tiles_status.buf, info, aie_status);
parse_mem_tile_buf(tiles_status.buf, info, aie_status_vec);
break;
default :
throw std::runtime_error("Unknown tile type in formatting AIE tiles status info");
}

struct aie_status result;
result.status = aie_status;
aie_status result;
result.status = std::move(aie_status_vec);
result.columns_filled = tiles_status.cols_filled;
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/info_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ add_mac_info(const xrt_core::device* device, ptree_type& pt)
auto mac_addr_first = xrt_core::device_query<xq::mac_addr_first>(device);

// new flow
if (mac_contiguous_num!=0 && !mac_addr_first.empty()) {
if (mac_contiguous_num != 0 && !mac_addr_first.empty()) {
// Convert the mac address into a number
uint64_t mac_addr_first_value = xrt_core::utils::mac_addr_to_value(mac_addr_first);

Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ sendv(severity_level l, const char* tag, const char* format, va_list args)
}
++len; //To include null terminator
std::vector<char> buf(len, 0);
std::vsnprintf(buf.data(), len, format, args);
std::ignore = std::vsnprintf(buf.data(), len, format, args);
send(l, tag, buf.data());
}

Expand Down
5 changes: 2 additions & 3 deletions src/runtime_src/core/common/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ read_data_driven_electrical(const std::vector<xq::sdm_sensor_info::data_type>& c

// iterate over current data, store to ptree by converting to Amps from milli Amps
for (const auto& tmp : voltage) {
auto desc = tmp.label;
pt.put("id", desc);
pt.put("description", desc);
pt.put("id", tmp.label);
pt.put("description", tmp.label);
/*
* Use below calculation for sensor values:
* actual sensor value = sensor_value * (10 ^ (unit_modifier))
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ mac_addr_to_value(std::string mac_addr)
}

std::string
value_to_mac_addr(const uint64_t mac_addr_value)
value_to_mac_addr(uint64_t mac_addr_value)
{
// Any bits higher than position 48 will be ignored
// If any are set throw an error as they cannot be placed into the mac address
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ mac_addr_to_value(std::string mac_addr);

XRT_CORE_COMMON_EXPORT
std::string
value_to_mac_addr(const uint64_t mac_addr_value);
value_to_mac_addr(uint64_t mac_addr_value);

XRT_CORE_COMMON_EXPORT
int
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/xclbin_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ get_kernel_arguments(const char* xml_data, size_t xml_size, const std::string& k
args.emplace_back(kernel_argument{
xml_arg.second.get<std::string>("<xmlattr>.name")
,xml_arg.second.get<std::string>("<xmlattr>.type", "no-type")
,port
,std::move(port)
,pwidth
,index
,convert(xml_arg.second.get<std::string>("<xmlattr>.offset"))
Expand Down
2 changes: 2 additions & 0 deletions src/runtime_src/core/include/experimental/xrt_elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class elf : public detail::pimpl<elf_impl>
elf() = default;

XRT_API_EXPORT
explicit
elf(const std::string& fnm);

/**
Expand All @@ -44,6 +45,7 @@ class elf : public detail::pimpl<elf_impl>
*
*/
XRT_API_EXPORT
explicit
elf(std::istream& stream);

XRT_API_EXPORT
Expand Down
1 change: 1 addition & 0 deletions src/runtime_src/core/include/experimental/xrt_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class runlist : public detail::pimpl<runlist_impl>
* Throws is invariant per run object hwctx requirement is violated.
*/
XRT_API_EXPORT
explicit
runlist(const xrt::hw_context& hwctx);

/**
Expand Down
1 change: 1 addition & 0 deletions src/runtime_src/core/include/experimental/xrt_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class module : public detail::pimpl<module_impl>
* The constructor retains ownership of the elf object.
*/
XRT_API_EXPORT
explicit
module(const xrt::elf& elf);

/**
Expand Down
16 changes: 15 additions & 1 deletion src/runtime_src/core/include/xrt/xrt_bo.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ struct pid_type { pid_t pid; };
class device;
class hw_context;
class bo_impl;
/*!
* @class bo
*
* @brief
* xrt::bo represents a buffer object that can be used as kernel argument
*/
class bo
{
public:
Expand Down Expand Up @@ -138,6 +144,12 @@ class bo

/**
* bo() - Constructor for empty bo
*
* A default constructed bo can be assigned to and can be used in a
* Boolean check along with comparison.
*
* Unless otherwise noted, it is undefined behavior to use xrt::bo
* APIs on a default constructed object.
*/
bo()
{}
Expand Down Expand Up @@ -469,6 +481,8 @@ class bo
*
* @return
* Size of buffer in bytes
*
* Returns 0 for a default constructed xrt::bo.
*/
XCL_DRIVER_DLLESPEC
size_t
Expand Down Expand Up @@ -498,7 +512,7 @@ class bo
* get_flags() - Get the flags with which this buffer was constructed
*
* @return
* The xrt::bo::Flgas used when the buffer was contructed
* The xrt::bo::flags used when the buffer was contructed
*/
XCL_DRIVER_DLLESPEC
flags
Expand Down

0 comments on commit c6951c9

Please sign in to comment.