Skip to content

Commit 620d7a4

Browse files
authored
Code clean (#721)
1 parent d814d2c commit 620d7a4

10 files changed

+25
-70
lines changed

lib/src/sai_redis_switch.cpp

+4-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "sai_redis.h"
22

3-
sai_status_t redis_switch_mdio_read(
3+
static sai_status_t redis_switch_mdio_read(
44
_In_ sai_object_id_t switch_id,
55
_In_ uint32_t device_addr,
66
_In_ uint32_t start_reg_addr,
@@ -12,7 +12,7 @@ sai_status_t redis_switch_mdio_read(
1212
return SAI_STATUS_NOT_IMPLEMENTED;
1313
}
1414

15-
sai_status_t redis_switch_mdio_write(
15+
static sai_status_t redis_switch_mdio_write(
1616
_In_ sai_object_id_t switch_id,
1717
_In_ uint32_t device_addr,
1818
_In_ uint32_t start_reg_addr,
@@ -41,30 +41,6 @@ static sai_status_t redis_create_switch_uniq(
4141
attr_list);
4242
}
4343

44-
static sai_status_t redis_mdio_read(
45-
_In_ sai_object_id_t switch_id,
46-
_In_ uint32_t device_addr,
47-
_In_ uint32_t start_reg_addr,
48-
_In_ uint32_t number_of_registers,
49-
_Out_ uint32_t *reg_val)
50-
{
51-
SWSS_LOG_ENTER();
52-
53-
return SAI_STATUS_NOT_IMPLEMENTED;
54-
}
55-
56-
static sai_status_t redis_mdio_write(
57-
_In_ sai_object_id_t switch_id,
58-
_In_ uint32_t device_addr,
59-
_In_ uint32_t start_reg_addr,
60-
_In_ uint32_t number_of_registers,
61-
_In_ const uint32_t *reg_val)
62-
{
63-
SWSS_LOG_ENTER();
64-
65-
return SAI_STATUS_NOT_IMPLEMENTED;
66-
}
67-
6844
const sai_switch_api_t redis_switch_api = {
6945

7046
redis_create_switch_uniq,
@@ -74,6 +50,6 @@ const sai_switch_api_t redis_switch_api = {
7450

7551
REDIS_GENERIC_STATS_API(switch)
7652

77-
redis_mdio_read,
78-
redis_mdio_write,
53+
redis_switch_mdio_read,
54+
redis_switch_mdio_write,
7955
};

meta/Meta.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -6083,21 +6083,6 @@ sai_status_t Meta::meta_generic_validate_non_object_on_create(
60836083

60846084
sai_object_id_t oid = m->getoid(&meta_key);
60856085

6086-
if (oid == SAI_NULL_OBJECT_ID)
6087-
{
6088-
if (meta_key.objecttype == SAI_OBJECT_TYPE_FDB_ENTRY)
6089-
{
6090-
SWSS_LOG_WARN("workaround: %s is NULL, REMOVE when using bv_id", m->membername);
6091-
continue;
6092-
}
6093-
6094-
SWSS_LOG_ERROR("oid on %s on struct member %s is NULL",
6095-
sai_serialize_object_type(meta_key.objecttype).c_str(),
6096-
m->membername);
6097-
6098-
return SAI_STATUS_INVALID_PARAMETER;
6099-
}
6100-
61016086
if (oid == SAI_NULL_OBJECT_ID)
61026087
{
61036088
SWSS_LOG_ERROR("oid on %s on struct member %s is NULL",

meta/saiserialize.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
using json = nlohmann::json;
1717

18-
int char_to_int(
18+
static int char_to_int(
1919
_In_ const char c)
2020
{
2121
SWSS_LOG_ENTER();
@@ -62,7 +62,7 @@ void sai_free_list(
6262
}
6363

6464
template<typename T>
65-
void transfer_primitive(
65+
static void transfer_primitive(
6666
_In_ const T &src_element,
6767
_In_ T &dst_element)
6868
{
@@ -75,7 +75,7 @@ void transfer_primitive(
7575
}
7676

7777
template<typename T>
78-
sai_status_t transfer_list(
78+
static sai_status_t transfer_list(
7979
_In_ const T &src_element,
8080
_In_ T &dst_element,
8181
_In_ bool countOnly)
@@ -457,7 +457,7 @@ sai_status_t transfer_attributes(
457457

458458
// util
459459

460-
uint8_t get_ip_mask(
460+
static uint8_t get_ip_mask(
461461
_In_ const uint8_t* mask,
462462
_In_ bool ipv6)
463463
{
@@ -488,23 +488,23 @@ uint8_t get_ip_mask(
488488
return ones;
489489
}
490490

491-
uint8_t get_ipv4_mask(
491+
static uint8_t get_ipv4_mask(
492492
_In_ const sai_ip4_t mask)
493493
{
494494
SWSS_LOG_ENTER();
495495

496496
return get_ip_mask((const uint8_t*)&mask, false);
497497
}
498498

499-
int get_ipv6_mask(
499+
static int get_ipv6_mask(
500500
_In_ const sai_ip6_t &mask)
501501
{
502502
SWSS_LOG_ENTER();
503503

504504
return get_ip_mask(mask, true);
505505
}
506506

507-
void sai_populate_ip_mask(
507+
static void sai_populate_ip_mask(
508508
_In_ uint8_t bits,
509509
_Out_ uint8_t *mask,
510510
_In_ bool ipv6)

syncd/AsicView.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ void AsicView::asicRemoveObject(
829829
break;
830830

831831
case SAI_OBJECT_TYPE_NAT_ENTRY:
832-
m_soNatEntries[currentObj->m_str_object_id] = currentObj;
832+
m_soNatEntries.erase(currentObj->m_str_object_id);
833833
break;
834834

835835
default:
@@ -1105,7 +1105,7 @@ void AsicView::dumpRef(const std::string & asicName)
11051105

11061106
SWSS_LOG_NOTICE("dump references in ASIC VIEW: %s", asicName.c_str());
11071107

1108-
for (auto kvp: m_vidReference)
1108+
for (auto& kvp: m_vidReference)
11091109
{
11101110
sai_object_id_t oid = kvp.first;
11111111

@@ -1137,7 +1137,7 @@ void AsicView::dumpVidToAsicOperatioId() const
11371137
{
11381138
SWSS_LOG_ENTER();
11391139

1140-
for (auto a: m_vidToAsicOperationId)
1140+
for (auto& a: m_vidToAsicOperationId)
11411141
{
11421142
auto ot = VidManager::objectTypeQuery(a.first);
11431143

@@ -1153,7 +1153,7 @@ void AsicView::populateAttributes(
11531153
{
11541154
SWSS_LOG_ENTER();
11551155

1156-
for (const auto &field: map)
1156+
for (const auto& field: map)
11571157
{
11581158
std::shared_ptr<SaiAttr> attr = std::make_shared<SaiAttr>(field.first, field.second);
11591159

@@ -1163,7 +1163,6 @@ void AsicView::populateAttributes(
11631163

11641164
switch (meta->attrid)
11651165
{
1166-
11671166
case SAI_ACL_COUNTER_ATTR_PACKETS:
11681167
case SAI_ACL_COUNTER_ATTR_BYTES:
11691168

@@ -1178,13 +1177,13 @@ void AsicView::populateAttributes(
11781177
break;
11791178
}
11801179
}
1180+
11811181
if (obj->getObjectType() == SAI_OBJECT_TYPE_NAT_ENTRY)
11821182
{
11831183
auto* meta = attr->getAttrMetadata();
11841184

11851185
switch (meta->attrid)
11861186
{
1187-
11881187
case SAI_NAT_ENTRY_ATTR_HIT_BIT_COR:
11891188
case SAI_NAT_ENTRY_ATTR_HIT_BIT:
11901189

syncd/SaiDiscovery.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ using namespace syncd;
1818
*/
1919
#define SAI_DISCOVERY_LIST_MAX_ELEMENTS 1024
2020

21-
2221
SaiDiscovery::SaiDiscovery(
2322
_In_ std::shared_ptr<sairedis::SaiInterface> sai):
2423
m_sai(sai)
@@ -88,7 +87,7 @@ void SaiDiscovery::discover(
8887
discovered.insert(rid);
8988
}
9089

91-
const sai_object_type_info_t *info = sai_metadata_get_object_type_info(ot);
90+
const sai_object_type_info_t *info = sai_metadata_get_object_type_info(ot);
9291

9392
/*
9493
* We will query only oid object types

syncd/SaiSwitch.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ SaiSwitch::SaiSwitch(
7979
}
8080
}
8181

82-
8382
/*
8483
* NOTE: all those methods could be implemented inside SaiSwitch class so then
8584
* we could skip using switch_id in params and even they could be public then.
@@ -749,7 +748,7 @@ std::set<sai_object_id_t> SaiSwitch::getWarmBootDiscoveredVids() const
749748
}
750749

751750
void SaiSwitch::redisSaveInternalOids(
752-
_In_ sai_object_id_t rid) const
751+
_In_ sai_object_id_t rid) const
753752
{
754753
SWSS_LOG_ENTER();
755754

@@ -767,13 +766,12 @@ void SaiSwitch::redisSaveInternalOids(
767766
* is SAI_SWITCH_ATTR_DEFAULT_STP_INST_ID which is discovered in warm-boot
768767
* when upgrading to new SAI Version*/
769768

770-
771769
m_client->setDummyAsicStateObject(vid);
772770

773771
m_client->saveColdBootDiscoveredVids(m_switch_vid, coldVids);
774772

775773
SWSS_LOG_NOTICE("put switch internal discovered rid %s to Asic View and COLDVIDS",
776-
sai_serialize_object_id(rid).c_str());
774+
sai_serialize_object_id(rid).c_str());
777775

778776
}
779777

@@ -1144,7 +1142,7 @@ void SaiSwitch::postPortRemove(
11441142
if (vid == SAI_NULL_OBJECT_ID)
11451143
{
11461144
SWSS_LOG_THROW("expected rid %s to be present in RIDTOVID",
1147-
sai_serialize_object_id(rid).c_str());
1145+
sai_serialize_object_id(rid).c_str());
11481146
}
11491147

11501148
// TODO should this remove rid,vid and object be as db op?
@@ -1165,7 +1163,7 @@ void SaiSwitch::postPortRemove(
11651163
if (removed == 0)
11661164
{
11671165
SWSS_LOG_THROW("NO LANES found in redis lane map for given port RID %s",
1168-
sai_serialize_object_id(portRid).c_str());
1166+
sai_serialize_object_id(portRid).c_str());
11691167
}
11701168

11711169
SWSS_LOG_NOTICE("post port remove actions succeeded");

syncd/Syncd.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1925,8 +1925,6 @@ void Syncd::syncUpdateRedisQuadEvent(
19251925

19261926
auto& values = kfvFieldsValues(kco);
19271927

1928-
const std::string& strObjectId = key.substr(key.find(":") + 1);
1929-
19301928
sai_object_meta_key_t metaKey;
19311929
sai_deserialize_object_meta_key(key, metaKey);
19321930

syncd/ZeroMQSelectableChannel.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ void ZeroMQSelectableChannel::pop(
156156

157157
if (m_queue.empty())
158158
{
159-
SWSS_LOG_ERROR("queue is empty, can't pop");
160-
throw std::runtime_error("queue is empty, can't pop");
159+
SWSS_LOG_THROW("queue is empty, can't pop");
161160
}
162161

163162
std::string msg = m_queue.front();

vslib/src/NetMsgRegistrar.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ void NetMsgRegistrar::run()
134134
}
135135
}
136136

137-
// TODO unregister messages when swss common pointer will be advanced
137+
swss::NetDispatcher::getInstance().unregisterMessageHandler(RTM_NEWLINK);
138+
swss::NetDispatcher::getInstance().unregisterMessageHandler(RTM_DELLINK);
138139

139140
SWSS_LOG_NOTICE("netlink msg listener ended");
140141
}

vslib/src/sai_vs_port.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "sai_vs.h"
22

3-
sai_status_t vs_clear_port_all_stats(
3+
static sai_status_t vs_clear_port_all_stats(
44
_In_ sai_object_id_t port_id)
55
{
66
SWSS_LOG_ENTER();

0 commit comments

Comments
 (0)