From f10425988270f142de60ff02c61cb8d77b9ac03e Mon Sep 17 00:00:00 2001 From: Ido Barnea Date: Tue, 14 Jun 2016 18:12:00 +0300 Subject: coverity fixes --- src/bp_sim.cpp | 2 +- src/flow_stat.cpp | 8 +++++--- src/flow_stat.h | 2 +- src/latency.cpp | 14 ++------------ src/latency.h | 2 ++ 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp index c9171ae5..78ae09d9 100755 --- a/src/bp_sim.cpp +++ b/src/bp_sim.cpp @@ -745,7 +745,7 @@ std::string double_to_human_str(double num, if (etype ==KBYE_1024){ f=1024.0; } - while ((abs_num > f ) && (i< max_cnt)){ + while ((abs_num > f ) && (i < max_cnt - 1)){ abs_num/=f; div*=f; i++; diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp index 98b9494b..71d3a74a 100644 --- a/src/flow_stat.cpp +++ b/src/flow_stat.cpp @@ -227,7 +227,7 @@ CFlowStatUserIdMap::add_user_id(uint32_t user_id, uint8_t proto) { << std::endl; #endif - CFlowStatUserIdInfo *new_id = new CFlowStatUserIdInfo(proto); + CFlowStatUserIdInfo *new_id; if (proto == PAYLOAD_RULE_PROTO) { new_id = new CFlowStatUserIdInfoPayload(proto); @@ -390,7 +390,8 @@ uint16_t CFlowStatUserIdMap::unmap(uint32_t user_id) { /************** class CFlowStatHwIdMap ***************/ CFlowStatHwIdMap::CFlowStatHwIdMap() { - m_map = NULL; + m_map = NULL; // must call create in order to work with the class + m_num_free = 0; // to make coverity happy, init this here too. } CFlowStatHwIdMap::~CFlowStatHwIdMap() { @@ -466,6 +467,7 @@ CFlowStatRuleMgr::CFlowStatRuleMgr() { m_hw_id_map_payload.create(MAX_FLOW_STATS_PAYLOAD); memset(m_rx_cant_count_err, 0, sizeof(m_rx_cant_count_err)); memset(m_tx_cant_count_err, 0, sizeof(m_tx_cant_count_err)); + m_num_ports = 0; // need to call create to init } CFlowStatRuleMgr::~CFlowStatRuleMgr() { @@ -480,7 +482,7 @@ void CFlowStatRuleMgr::create() { m_api = tstateless->get_platform_api(); assert(m_api); m_api->get_interface_stat_info(0, num_counters, cap); - m_api->get_port_num(m_num_ports); + m_api->get_port_num(m_num_ports); // This initialize m_num_ports for (uint8_t port = 0; port < m_num_ports; port++) { assert(m_api->reset_hw_flow_stats(port) == 0); } diff --git a/src/flow_stat.h b/src/flow_stat.h index 8671b228..eae484e7 100644 --- a/src/flow_stat.h +++ b/src/flow_stat.h @@ -472,7 +472,7 @@ class CFlowStatRuleMgr { const CRxCoreStateless *m_rx_core; int m_max_hw_id; // max hw id we ever used int m_max_hw_id_payload; // max hw id we ever used for payload rules - uint32_t m_num_started_streams; // How many started (transmitting) streams we have + int m_num_started_streams; // How many started (transmitting) streams we have CNodeRing *m_ring_to_rx; // handle for sending messages to Rx core CFlowStatParser *m_parser; uint16_t m_cap; // capabilities of the NIC driver we are using diff --git a/src/latency.cpp b/src/latency.cpp index acbe26d4..6e4ce643 100644 --- a/src/latency.cpp +++ b/src/latency.cpp @@ -338,9 +338,7 @@ bool CCPortLatency::dump_packet(rte_mbuf_t * m){ uint16_t pkt_size=rte_pktmbuf_pkt_len(m); utl_DumpBuffer(stdout,p,pkt_size,0); return (0); - - - +#if 0 if (pkt_size < ( sizeof(CRx_check_header)+14+20) ) { assert(0); } @@ -348,16 +346,8 @@ bool CCPortLatency::dump_packet(rte_mbuf_t * m){ lp->dump(stdout); - - uint16_t vlan_offset=0; - if ( unlikely( CGlobalInfo::m_options.preview.get_vlan_mode_enable() ) ){ - vlan_offset=4; - } - - (void)vlan_offset; - -// utl_DumpBuffer(stdout,p,pkt_size,0); return (0); +#endif } diff --git a/src/latency.h b/src/latency.h index 2b74f737..6eddb3d7 100644 --- a/src/latency.h +++ b/src/latency.h @@ -85,6 +85,7 @@ public: CSimplePacketParser(rte_mbuf_t * m){ m_m=m; + m_l4 = NULL; } bool Parse(); @@ -269,6 +270,7 @@ public: CLatencyManagerCfg (){ m_max_ports=0; m_cps=0.0; + memset(m_ports, 0, sizeof(m_ports)); m_client_ip.v4=0x10000000; m_server_ip.v4=0x20000000; m_dual_port_mask=0x01000000; -- cgit 1.2.3-korg