Skip to content
Open
2 changes: 1 addition & 1 deletion contrib/jenkins_tests/cov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ eval "cov-manage-emit --config ${cov_dir}/coverity_config.xml --dir ${cov_build}
sleep 1

eval "cov-analyze --config ${cov_dir}/coverity_config.xml \
--all --aggressiveness-level low \
--all --aggressiveness-level medium \
--enable-fnptr --fnptr-models --paths 20000 \
--disable-parse-warnings \
--dir ${cov_build}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void json_descriptor_provider::validate_schema(json_object *schema)
}

json_object *type_field = json_utils::get_field(schema, config_strings::schema::JSON_TYPE);
if (std::string(json_object_get_string(type_field)) !=
if (type_field && std::string(json_object_get_string(type_field)) !=
config_strings::schema_types::JSON_TYPE_OBJECT) {
throw_xlio_exception("Schema root must have type 'object'.");
}
Expand Down
20 changes: 15 additions & 5 deletions src/core/config/descriptor_providers/schema_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,13 @@ constraint_config schema_analyzer::analyze_constraint_config()
for_each_oneof_option(one_of_field, [&](json_object *option) {
json_object *type_field =
json_utils::get_field(option, config_strings::schema::JSON_TYPE);
std::string type_str = json_object_get_string(type_field);
if (type_str == config_strings::schema_types::JSON_TYPE_INTEGER) {
extract_constraints_from_json(option, config);
}
const char *type_cstr = json_object_get_string(type_field);
if (type_cstr) {
std::string type_str = type_cstr;
if (type_str == config_strings::schema_types::JSON_TYPE_INTEGER) {
extract_constraints_from_json(option, config);
}
}
});
}

Expand Down Expand Up @@ -269,7 +272,14 @@ enum_mapping_config_t schema_analyzer::analyze_enum_mapping_config()
for_each_oneof_option(one_of_field, [&](json_object *option) {
json_object *type_field = json_utils::get_field(option, config_strings::schema::JSON_TYPE);

std::string type_str = json_object_get_string(type_field);
// Check for NULL before creating std::string
const char *type_cstr = json_object_get_string(type_field);
if (!type_cstr) {
// Skip this option if type is not a string or doesn't exist
throw_xlio_exception("Type is not a string or doesn't exist for: " + m_path);
}

std::string type_str = type_cstr;
if (type_str == config_strings::schema_types::JSON_TYPE_INTEGER) {
int_option = option;
} else if (type_str == config_strings::schema_types::JSON_TYPE_STRING) {
Expand Down
3 changes: 3 additions & 0 deletions src/core/config/loaders/inline_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ void inline_loader::parse_inline_data()
validate_key_value_pair(kv);

const std::string::size_type eq_pos = kv.find(EQUALS);
if (eq_pos == std::string::npos) {
throw_parsing_error("Missing equals sign in pair: " + kv, m_inline_config);
}
std::string key = kv.substr(0, eq_pos);
std::string val = kv.substr(eq_pos + 1);

Expand Down
21 changes: 12 additions & 9 deletions src/core/dev/hw_queue_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ bool hw_queue_rx::configure_rq(ibv_comp_channel *rx_comp_event_channel)

xlio_ib_mlx5_cq_t mlx5_cq;
memset(&mlx5_cq, 0, sizeof(mlx5_cq));
xlio_ib_mlx5_get_cq(m_p_cq_mgr_rx->get_ibv_cq_hndl(), &mlx5_cq);

hwqrx_logdbg(
"Creating RQ of transport type '%s' on ibv device '%s' [%p], cq: %p(%u), wre: %d, sge: %d",
priv_xlio_transport_type_str(m_p_ring->get_transport_type()),
m_p_ib_ctx_handler->get_ibname(), m_p_ib_ctx_handler->get_ibv_device(), m_p_cq_mgr_rx,
mlx5_cq.cq_num, m_rx_num_wr, m_rx_sge);

if (unlikely(xlio_ib_mlx5_get_cq(m_p_cq_mgr_rx->get_ibv_cq_hndl(), &mlx5_cq) != 0)) {
hwqrx_logdbg("Failed to get CQ (errno=%d %m)", errno);
} else {
hwqrx_logdbg("Creating RQ of transport type '%s' on ibv device '%s' [%p], cq: %p(%u), wre: "
"%d, sge: %d",
priv_xlio_transport_type_str(m_p_ring->get_transport_type()),
m_p_ib_ctx_handler->get_ibname(), m_p_ib_ctx_handler->get_ibv_device(),
m_p_cq_mgr_rx, mlx5_cq.cq_num, m_rx_num_wr, m_rx_sge);
}
if (safe_mce_sys().enable_striding_rq) {
m_rx_sge = 2U; // Striding-RQ needs a reserved segment.
m_strq_wqe_reserved_seg = 1U;
Expand Down Expand Up @@ -206,7 +207,9 @@ void hw_queue_rx::post_recv_buffers(descq_t *p_buffers, size_t count)
hwqrx_logfuncall("");
// Called from cq_mgr_rx context under cq_mgr_rx::LOCK!
while (count--) {
post_recv_buffer(p_buffers->get_and_pop_front());
if (likely(!p_buffers->empty())) {
post_recv_buffer(p_buffers->get_and_pop_front());
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/core/dev/hw_queue_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ inline uint8_t hw_queue_tx::fill_wqe(xlio_ibv_send_wr *pswr)

// Fill Ethernet segment with header inline, static data
// were populated in preset after previous packet send
/* coverity[null_deref] */
memcpy(cur_seg + offsetof(struct mlx5_wqe_eth_seg, inline_hdr_start), data_addr,
MLX5_ETH_INLINE_HEADER_SIZE);
cur_seg += sizeof(struct mlx5_wqe_eth_seg);
Expand Down
7 changes: 5 additions & 2 deletions src/core/dev/rfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,11 @@ bool rfs::attach_flow(sockinfo *sink)
if (g_p_app->type != APP_NONE && g_p_app->add_second_4t_rule) {
// This is second 4 tuple rule for the same worker (when number
// of workers is not power of two)
create_flow();
rfs_logdbg("Added second rule to worker: %d", g_p_app->get_worker_id());
if (!create_flow()) {
rfs_logdbg("Failed to create second rule for worker: %d", g_p_app->get_worker_id());
} else {
rfs_logdbg("Added second rule to worker: %d", g_p_app->get_worker_id());
}
}
#endif
}
Expand Down
6 changes: 5 additions & 1 deletion src/core/dev/ring_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ ring_simple::ring_simple(int if_index, ring *parent, bool use_locks)
BULLSEYE_EXCLUDE_BLOCK_END

const slave_data_t *p_slave = p_ndev->get_slave(get_if_index());

if(unlikely(!p_slave)) {
ring_logerr("Cannot find slave for a ring");
throw_xlio_exception("Cannot find slave for a ring");
}
ring_logdbg("new ring_simple()");

BULLSEYE_EXCLUDE_BLOCK_START
Expand Down Expand Up @@ -789,6 +792,7 @@ mem_buf_desc_t *ring_simple::get_tx_buffers(pbuf_type type, uint32_t n_num_mem_b
}

head = pool.get_and_pop_back();
/* coverity[null_deref] */
head->lwip_pbuf.ref = 1;
assert(head->lwip_pbuf.type == type);
head->lwip_pbuf.type = type;
Expand Down
2 changes: 2 additions & 0 deletions src/core/event/entity_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ void entity_context::add_incoming_socket(sockinfo *sock)
void entity_context::rx_data_recvd_job(const job_desc &job)
{
if (job.buf) {
/* coverity[check_return] */
job.buf->p_desc_owner->reclaim_recv_buffers(job.buf);
}

if (job.sock) {
/* coverity[check_return] */
job.sock->rx_data_recvd(job.tot_size);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/core/ib/mlx5/ib_mlx5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int xlio_ib_mlx5_get_qp_tx(xlio_ib_mlx5_qp_t *mlx5_qp)

VALGRIND_MAKE_MEM_DEFINED(&dqp, sizeof(dqp));
mlx5_qp->qpn = mlx5_qp->qp->qp_num;
/* coverity[var_deref_op] dbrec is guaranteed to be valid after successful xlio_ib_mlx5dv_init_obj */
mlx5_qp->sq.dbrec = &dqp.dbrec[MLX5_SND_DBR];
mlx5_qp->sq.buf = dqp.sq.buf;
mlx5_qp->sq.wqe_cnt = dqp.sq.wqe_cnt;
Expand Down
4 changes: 4 additions & 0 deletions src/core/lwip/tcp_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,10 @@ err_t tcp_write_express(struct tcp_pcb *pcb, const struct iovec *iov, u32_t iovc
assert(pcb->last_unsent->p->tot_len == last_seglen);
}
}
/* Restore desc->opaque on error path to match success path behavior. */
if (desc->attr == PBUF_DESC_EXPRESS) {
desc->opaque = opaque;
}
return ERR_MEM;
}

Expand Down
1 change: 1 addition & 0 deletions src/core/proto/neighbour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ void neigh_entry::handle_neigh_event(neigh_nl_event *nl_ev)
}

// Check if neigh L2 address changed (HA event) and restart the state machine
/* coverity[check_return] */
priv_handle_neigh_is_l2_changed(nl_info->lladdr);
break;
}
Expand Down
20 changes: 18 additions & 2 deletions src/core/sock/sock-redirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,32 @@
#include <set>

#ifdef XLIO_STATIC_BUILD

#define XLIO_SYMBOL(_func) xlio_##_func
#define SYSCALL(_func, ...) ::_func(__VA_ARGS__)
#define XLIO_CALL(_func, ...) xlio_##_func(__VA_ARGS__)
#define SYSCALL_ERRNO_UNSUPPORTED(_func, ...) SYSCALL(_func, __VA_ARGS__)
#define VALID_SYSCALL(_func) (true)
#else
#define XLIO_SYMBOL(_func) _func
#ifdef __COVERITY__
#define COVERITY_VAR_DEREF_OP \
_Pragma("coverity compliance deviate \"var_deref_op\" \
\"Intentional dereference; pointer validated elsewhere\"")
#else
#define COVERITY_VAR_DEREF_OP
#endif

#define VALID_SYSCALL(_func) ((orig_os_api._func) != nullptr)
#define SYSCALL(_func, ...) \
((VALID_SYSCALL(_func) ? (void)0 : get_orig_funcs()), orig_os_api._func(__VA_ARGS__))

#define SYSCALL(_func, ...) \
__extension__({ \
if (!VALID_SYSCALL(_func)) { \
get_orig_funcs(); \
} \
COVERITY_VAR_DEREF_OP \
orig_os_api._func(__VA_ARGS__); \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: The semicolon at the end prevents this statement expression from returning a value. GNU statement expressions require the last expression to be without a semicolon to return its value.

Suggested change
orig_os_api._func(__VA_ARGS__); \
orig_os_api._func(__VA_ARGS__)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: semicolon prevents statement expression from returning value - GNU statement expressions need last statement without semicolon to return its value (SYSCALL is used to capture return values in utils.cpp:479, 493, etc.)

Suggested change
orig_os_api._func(__VA_ARGS__); \
orig_os_api._func(__VA_ARGS__)

})
#define SYSCALL_ERRNO_UNSUPPORTED(_func, ...) \
(VALID_SYSCALL(_func) ? orig_os_api._func(__VA_ARGS__) : ((errno = EOPNOTSUPP), -1))
#define XLIO_CALL(_func, ...) _func(__VA_ARGS__)
Expand Down
10 changes: 8 additions & 2 deletions src/core/sock/sockinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,9 @@ bool sockinfo::attach_receiver(flow_tuple_with_local_if &flow_key)
rx_flow_map_t::iterator rx_flow_iter = m_rx_flow_map.find(flow_key_3t);
if (rx_flow_iter != m_rx_flow_map.end()) {
si_logdbg("Removing (and detaching) 3 tuple now that we added a stronger 5 tuple");
detach_receiver(flow_key_3t);
if (!detach_receiver(flow_key_3t)) {
si_logerr("Failed to detach 3 tuple flow key %s", flow_key_3t.to_str().c_str());
}
}
}

Expand Down Expand Up @@ -1660,6 +1662,7 @@ void sockinfo::move_descs(ring *p_ring, descq_t *toq, descq_t *fromq, bool own)
for (size_t i = 0; i < size; i++) {
temp = fromq->front();
fromq->pop_front();
/* coverity[NULL_DEREFERENCE] */
if (!__xor(own, p_ring->is_member(temp->p_desc_owner))) {
toq->push_back(temp);
} else {
Expand Down Expand Up @@ -1701,6 +1704,7 @@ void sockinfo::push_descs_rx_ready(descq_t *cache)
temp = cache->front();
cache->pop_front();
m_n_rx_pkt_ready_list_count++;
/* coverity[NULL_DEREFERENCE] */
m_rx_ready_byte_count += temp->rx.sz_payload;
if (m_p_socket_stats) {
m_p_socket_stats->n_rx_ready_pkt_count++;
Expand Down Expand Up @@ -1870,7 +1874,9 @@ void sockinfo::shutdown_rx()
rx_flow_map_t::iterator rx_flow_iter = m_rx_flow_map.begin();
while (rx_flow_iter != m_rx_flow_map.end()) {
flow_tuple_with_local_if detach_key = rx_flow_iter->first;
detach_receiver(detach_key);
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
Comment on lines +1877 to +1878
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inverted logic - detach_receiver returns true on SUCCESS (line 950 returns result of destroy_nd_resources which returns true on success at line 1061), so this logs "Failed" when detach actually succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1878
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: inverted logic - detach_receiver returns true on SUCCESS, so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

}
Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inverted logic - detach_receiver returns true on SUCCESS (line 950 in sockinfo.cpp), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inverted logic - detach_receiver returns true on SUCCESS (line 950 returns result of destroy_nd_resources, which returns true on success at line 1061), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inverted logic - detach_receiver returns true on success (line 950 returns result of destroy_nd_resources, which returns true on success at line 1061), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inverted logic - detach_receiver returns true on SUCCESS (line 950 returns result of destroy_nd_resources which returns true on success at line 1061), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inverted logic - detach_receiver returns true on SUCCESS (line 950), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inverted logic - detach_receiver returns true on SUCCESS (line 950 returns result of destroy_nd_resources, which returns true on success at line 1061), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inverted logic - detach_receiver returns true on SUCCESS (line 950), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Inverted logic - detach_receiver returns true on SUCCESS (line 950 returns result of destroy_nd_resources, which returns true on success at line 1061), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: inverted logic - detach_receiver returns true on SUCCESS (line 950 returns result of destroy_nd_resources, which returns true on success at line 1061), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

Comment on lines +1877 to +1879
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: inverted logic - detach_receiver returns true on SUCCESS (line 950 returns result of destroy_nd_resources, which returns true on success at line 1061), so this logs "Failed" when detach succeeds

Suggested change
if (detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}
if (!detach_receiver(detach_key)) {
si_logdbg("Failed to detach receiver for socket %p", this);
}

rx_flow_iter = m_rx_flow_map.begin(); // Pop next flow rule
}

Expand Down
19 changes: 13 additions & 6 deletions src/core/sock/sockinfo_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,21 @@ void sockinfo_tcp::listen_entity_context()
{

std::lock_guard<decltype(m_tcp_con_lock)> lock(m_tcp_con_lock);

sockinfo_tcp_listen_context *parent_listen_context = get_parent_listen_context();
if (!attach_as_uc_receiver(ROLE_TCP_SERVER)) {
get_parent_listen_context()->increment_error_counter();
if (likely(parent_listen_context)) {
parent_listen_context->increment_error_counter();
}
si_tcp_logerr(
"Unable to attach uc receiver for listen socket rss_child in entity context.");
return;
}

// Set socket state to accept ready
m_sock_state = TCP_SOCK_ACCEPT_READY;
get_parent_listen_context()->increment_finish_counter();
if (likely(parent_listen_context)) {
parent_listen_context->increment_finish_counter();
}

si_tcp_logdbg("Listen socket successfully setup in entity context (sock: %p, backlog: %d)",
this, m_backlog);
Expand Down Expand Up @@ -899,6 +903,7 @@ void sockinfo_tcp::clear_rx_ready_buffers()
while (m_n_rx_pkt_ready_list_count) {
mem_buf_desc_t *p_rx_pkt_desc = m_rx_pkt_ready_list.get_and_pop_front();
m_n_rx_pkt_ready_list_count--;
/* coverity[NULL_DEREFERENCE] */
m_rx_ready_byte_count -= p_rx_pkt_desc->rx.sz_payload;
if (m_p_socket_stats) {
m_p_socket_stats->n_rx_ready_pkt_count--;
Expand Down Expand Up @@ -2804,7 +2809,7 @@ int sockinfo_tcp::connect(const sockaddr *__to, socklen_t __tolen)
connect_threads_mode();
return -1; // Currently no blocking socket support.
}

/* coverity[check_return] */
prepare_dst_to_send(false);

if (!connect_bind_any_and_check_rules()) {
Expand Down Expand Up @@ -2900,8 +2905,9 @@ bool sockinfo_tcp::connect_bind_any_and_check_rules()
}

if (bound_any_addr) {
tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6);
if(unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6)!=0))
return false;
Comment on lines +2908 to +2910
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Missing closing brace - this will cause compilation failure

Suggested change
if(unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6)!=0))
return false;
if (unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6) != 0)) {
return false;
}

Comment on lines +2908 to +2910
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Formatting needs improvement - add space after if, around !=, and proper indentation

Suggested change
if(unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6)!=0))
return false;
if (unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6) != 0)) {
return false;
}

Comment on lines +2908 to +2910
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Inconsistent formatting - missing space after if and around !=

Suggested change
if(unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6)!=0))
return false;
if (unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6) != 0)) {
return false;
}

Comment on lines +2908 to +2910
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Missing space after if and around != operator - inconsistent with codebase formatting

Suggested change
if(unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6)!=0))
return false;
if (unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6) != 0)) {
return false;
}

Comment on lines +2908 to +2910
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Inconsistent formatting - missing space after if and around != operator

Suggested change
if(unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6)!=0))
return false;
if (unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6) != 0)) {
return false;

Comment on lines +2908 to +2910
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Missing space after if and around != operator - inconsistent with codebase formatting

Suggested change
if(unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6)!=0))
return false;
if (unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6) != 0)) {
return false;
}

Comment on lines +2908 to +2910
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Add space after if, around !=, and wrap in braces for consistency with codebase style

Suggested change
if(unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6)!=0))
return false;
if (unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6) != 0)) {
return false;
}

Comment on lines +2908 to +2910
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: missing space after if, around !=, and body should be in braces for consistency

Suggested change
if(unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6)!=0))
return false;
if (unlikely(tcp_bind(&m_pcb, reinterpret_cast<const ip_addr_t *>(&m_bound.get_ip_addr()),
ntohs(m_bound.get_in_port()), m_pcb.is_ipv6) != 0)) {
return false;
}

}

m_conn_state = TCP_CONN_CONNECTING;
Expand Down Expand Up @@ -3720,6 +3726,7 @@ err_t sockinfo_tcp::accept_lwip_cb(void *arg, struct tcp_pcb *child_pcb, err_t e
/* if attach failed, we should continue getting traffic through the listen socket */
// todo register as 3-tuple rule for the case the listener is gone?
if (!new_sock->m_b_attached) {
/* coverity[check_return] */
new_sock->attach_as_uc_receiver(role_t(NULL), true);
new_sock->m_b_attached = true;
}
Expand Down
7 changes: 6 additions & 1 deletion src/core/sock/sockinfo_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ struct socket_option_t {
, optlen(_optlen)
, optval(malloc(optlen))
{
memcpy(optval, _optval, optlen);
if(likely(optval)) {
memcpy(optval, _optval, optlen);
} else {
__log_dbg("Unable to allocate memory for socket option level=%d, optname=%d",
_level, _optname);
}
}

~socket_option_t()
Expand Down
7 changes: 6 additions & 1 deletion src/core/sock/sockinfo_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,12 @@ ssize_t sockinfo_udp::tx(xlio_tx_call_attr_t &tx_arg)

tx_packet_to_os:
// Calling OS transmit
ret = tx_os(tx_arg.opcode, p_iov, sz_iov, __flags, __dst, __dstlen);
if (unlikely(!p_iov)) {
errno = EINVAL;
ret = -1;
} else {
ret = tx_os(tx_arg.opcode, p_iov, sz_iov, __flags, __dst, __dstlen);
}

tx_packet_to_os_stats:
save_stats_tx_os(ret);
Expand Down
1 change: 1 addition & 0 deletions src/core/util/chunk_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ template <typename T> class chunk_list_t {
if (unlikely(empty())) {
return NULL;
}
/* coverity[NULL_DEREFERENCE] */
return m_used_containers.front()->m_p_buffer[m_front];
}

Expand Down
1 change: 1 addition & 0 deletions src/state_machine/sm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ int state_machine::process_event(int event, void *ev_data)

// Run print event info function
if (m_new_event_notify_func) {
/* coverity[check_return][unchecked_value] */
m_new_event_notify_func(get_curr_state(), event, m_info.app_hndl);
}

Expand Down
5 changes: 2 additions & 3 deletions src/stats/stats_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1626,9 +1626,8 @@ void stats_reader_handler(sh_mem_t *p_sh_mem, int pid)
}
switch (user_params.print_details_mode) {
case e_totals:
num_act_inst =
show_socket_stats(p_sh_mem->skt_inst_arr, NULL, p_sh_mem->max_skt_inst_num,
&printed_line_num, &p_sh_mem->mc_info, pid);
/* coverity[forward_null] */
num_act_inst = show_socket_stats(p_sh_mem->skt_inst_arr, NULL, p_sh_mem->max_skt_inst_num, &printed_line_num, &p_sh_mem->mc_info, pid);
show_iomux_stats(&p_sh_mem->iomux, NULL, &printed_line_num);
if (user_params.view_mode == e_full) {
show_cq_stats(p_sh_mem->cq_inst_arr, NULL);
Expand Down