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

[sairedis] Replace memset functions #1110

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions syncd/ComparisonLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2531,9 +2531,7 @@ bool ComparisonLogic::checkAsicVsDatabaseConsistency(

auto info = sai_metadata_get_object_type_info(obj->getObjectType());

sai_attribute_t attr;

memset(&attr, 0, sizeof(attr));
sai_attribute_t attr = {};

if (attrs.size() == 0)
{
Expand Down
6 changes: 2 additions & 4 deletions syncd/MdioIpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ int MdioIpcServer::syncd_ipc_task_main()
int sock_srv;
int sock_cli;
int sock_max;
syncd_mdio_ipc_conn_t conn[CONN_MAX];
struct sockaddr_un addr;
syncd_mdio_ipc_conn_t conn[CONN_MAX] = {};
struct sockaddr_un addr = {};
char path[64];
fd_set rfds;
char cmd[SYNCD_IPC_BUFF_SIZE], resp[SYNCD_IPC_BUFF_SIZE], *argv[64], *save;
Expand Down Expand Up @@ -224,7 +224,6 @@ int MdioIpcServer::syncd_ipc_task_main()
/* Delete the file so the bind will */
/* succeed, then bind to that file. */
/***************************************/
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
sprintf(addr.sun_path, "%s/%s.srv", path, SYNCD_IPC_SOCK_FILE);
unlink(addr.sun_path);
Expand All @@ -246,7 +245,6 @@ int MdioIpcServer::syncd_ipc_task_main()

SWSS_LOG_NOTICE("IPC service is online\n");

memset(conn, 0, sizeof(conn));
while (m_taskAlive)
{
time_t now;
Expand Down
8 changes: 2 additions & 6 deletions syncd/SaiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ std::string SaiSwitch::saiGetHardwareInfo() const

sai_attribute_t attr;

char info[MAX_HARDWARE_INFO_LENGTH];

memset(info, 0, MAX_HARDWARE_INFO_LENGTH);
char info[MAX_HARDWARE_INFO_LENGTH] = {0};

attr.id = SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO;

Expand Down Expand Up @@ -241,9 +239,7 @@ std::unordered_map<sai_uint32_t, sai_object_id_t> SaiSwitch::saiGetHardwareLaneM

for (const auto &port_rid: portList)
{
sai_uint32_t lanes[MAX_LANES_PER_PORT];

memset(lanes, 0, sizeof(lanes));
sai_uint32_t lanes[MAX_LANES_PER_PORT] = {0};

sai_attribute_t attr;

Expand Down
4 changes: 1 addition & 3 deletions unittest/lib/TestContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ static sai_switch_notifications_t handle_notification(
{
SWSS_LOG_ENTER();

sai_switch_notifications_t ntf;

memset(&ntf, 0, sizeof(ntf));
sai_switch_notifications_t ntf = {};

return ntf;
}
Expand Down
4 changes: 1 addition & 3 deletions unittest/meta/TestAttrKeyMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ TEST(AttrKeyMap, constructKey)
{
auto akm = std::make_shared<AttrKeyMap>();

sai_object_meta_key_t mk;

memset(&mk, 0, sizeof(mk));
sai_object_meta_key_t mk = {};

EXPECT_THROW(
akm->constructKey(SAI_NULL_OBJECT_ID, mk, 0, nullptr),
Expand Down
8 changes: 2 additions & 6 deletions unittest/meta/TestLegacyFdbEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ TEST(LegacyFdbEntry, fdb_entry_set)
clear_local();

sai_status_t status;
sai_attribute_t attr;

memset(&attr, 0, sizeof(attr));
sai_attribute_t attr = {};

sai_fdb_entry_t fdb_entry = create_fdb_entry();

Expand Down Expand Up @@ -288,9 +286,7 @@ TEST(LegacyFdbEntry, fdb_entry_get)
clear_local();

sai_status_t status;
sai_attribute_t attr;

memset(&attr, 0, sizeof(attr));
sai_attribute_t attr = {};

sai_fdb_entry_t fdb_entry = create_fdb_entry();

Expand Down
8 changes: 2 additions & 6 deletions unittest/meta/TestLegacyNeighborEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ TEST(LegacyNeighborEntry, neighbor_entry_set)

sai_status_t status;

sai_attribute_t attr;

memset(&attr, 0, sizeof(attr));
sai_attribute_t attr = {};

sai_object_id_t switch_id = create_switch();
sai_neighbor_entry_t neighbor_entry;
Expand Down Expand Up @@ -317,9 +315,7 @@ TEST(LegacyNeighborEntry, neighbor_entry_get)

sai_status_t status;

sai_attribute_t attr;

memset(&attr, 0, sizeof(attr));
sai_attribute_t attr = {};

sai_object_id_t switch_id = create_switch();
sai_neighbor_entry_t neighbor_entry;
Expand Down
12 changes: 3 additions & 9 deletions unittest/meta/TestLegacyOther.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ TEST(Legacy, switch_set)
clear_local();

sai_status_t status;
sai_attribute_t attr;

memset(&attr, 0, sizeof(attr));
sai_attribute_t attr = {};

sai_object_id_t switch_id = create_switch();

Expand Down Expand Up @@ -330,9 +328,7 @@ TEST(Legacy, switch_get)
clear_local();

sai_status_t status;
sai_attribute_t attr;

memset(&attr, 0, sizeof(attr));
sai_attribute_t attr = {};

sai_object_id_t switch_id = create_switch();

Expand Down Expand Up @@ -742,9 +738,7 @@ TEST(Legacy, acl_entry_field_and_action)

for (uint32_t i = 0; i < sizeof(ids)/sizeof(int32_t); ++i)
{
sai_attribute_t attr;

memset(&attr,0,sizeof(attr));
sai_attribute_t attr = {};

attr.value.aclfield.enable = true;
attr.value.aclaction.enable = true;
Expand Down
8 changes: 2 additions & 6 deletions unittest/meta/TestLegacyRouteEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ TEST(LegacyRouteEntry, route_entry_set)
clear_local();

sai_status_t status;
sai_attribute_t attr;
sai_attribute_t attr = {};
sai_object_id_t switch_id = create_switch();

memset(&attr, 0, sizeof(attr));

sai_route_entry_t route_entry;

sai_object_id_t vr = create_virtual_router(switch_id);
Expand Down Expand Up @@ -330,11 +328,9 @@ TEST(LegacyRouteEntry, route_entry_get)
clear_local();

sai_status_t status;
sai_attribute_t attr;
sai_attribute_t attr = {};
sai_object_id_t switch_id = create_switch();

memset(&attr, 0, sizeof(attr));

sai_route_entry_t route_entry;

sai_object_id_t vr = create_virtual_router(switch_id);
Expand Down
8 changes: 2 additions & 6 deletions unittest/meta/TestLegacyVlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ TEST(LegacyVlan, vlan_set)

sai_status_t status;

sai_attribute_t attr;

memset(&attr, 0, sizeof(attr));
sai_attribute_t attr = {};

sai_attribute_t vlan1_att;
vlan1_att.id = SAI_VLAN_ATTR_VLAN_ID;
Expand Down Expand Up @@ -247,9 +245,7 @@ TEST(LegacyVlan, vlan_get)
sai_object_id_t switch_id = create_switch();
sai_status_t status;

sai_attribute_t attr;

memset(&attr, 0, sizeof(attr));
sai_attribute_t attr = {};

sai_attribute_t vlan1_att;
vlan1_att.id = SAI_VLAN_ATTR_VLAN_ID;
Expand Down
40 changes: 10 additions & 30 deletions unittest/meta/TestMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ TEST(Meta, quad_mcast_fdb_entry)
attrs[1].id = SAI_MCAST_FDB_ENTRY_ATTR_PACKET_ACTION;
attrs[1].value.s32 = SAI_PACKET_ACTION_FORWARD;

sai_mcast_fdb_entry_t e;

memset(&e, 0, sizeof(e));
sai_mcast_fdb_entry_t e = {};

e.bv_id = vlanId;
e.switch_id = switchId;
Expand Down Expand Up @@ -103,9 +101,7 @@ TEST(Meta, quad_l2mc_entry)
attr.id = SAI_L2MC_ENTRY_ATTR_PACKET_ACTION;
attr.value.s32 = SAI_PACKET_ACTION_FORWARD;

sai_l2mc_entry_t e;

memset(&e, 0, sizeof(e));
sai_l2mc_entry_t e = {};

e.bv_id = vlanId;
e.switch_id = switchId;
Expand Down Expand Up @@ -147,9 +143,7 @@ TEST(Meta, quad_inseg_entry)
attr.id = SAI_L2MC_ENTRY_ATTR_PACKET_ACTION;
attr.value.s32 = SAI_PACKET_ACTION_FORWARD;

sai_inseg_entry_t e;

memset(&e, 0, sizeof(e));
sai_inseg_entry_t e = {};

e.switch_id = switchId;
e.label = 1;
Expand Down Expand Up @@ -188,9 +182,7 @@ TEST(Meta, quad_nat_entry)
attr.id = SAI_NAT_ENTRY_ATTR_NAT_TYPE;
attr.value.s32 = SAI_NAT_TYPE_NONE;

sai_nat_entry_t e;

memset(&e, 0, sizeof(e));
sai_nat_entry_t e = {};

e.switch_id = switchId;
e.vr_id = vrId;
Expand Down Expand Up @@ -238,9 +230,7 @@ TEST(Meta, quad_impc_entry)
attrs[1].id = SAI_IPMC_ENTRY_ATTR_RPF_GROUP_ID;
attrs[1].value.oid = rpfGroupId;

sai_ipmc_entry_t e;

memset(&e, 0, sizeof(e));
sai_ipmc_entry_t e = {};

e.switch_id = switchId;
e.vr_id = vrId;
Expand Down Expand Up @@ -582,9 +572,7 @@ TEST(Meta, quad_my_sid_entry)
attrs[0].id = SAI_MY_SID_ENTRY_ATTR_ENDPOINT_BEHAVIOR;
attrs[0].value.s32 = SAI_MY_SID_ENTRY_ENDPOINT_BEHAVIOR_E;

sai_my_sid_entry_t e;

memset(&e, 0, sizeof(e));
sai_my_sid_entry_t e = {};

e.switch_id = switchId;
e.vr_id = vrId;
Expand Down Expand Up @@ -629,9 +617,7 @@ TEST(Meta, quad_bulk_route_entry)

// create

sai_route_entry_t e[2];

memset(e, 0, sizeof(e));
sai_route_entry_t e[2] = {};

e[0].switch_id = switchId;
e[1].switch_id = switchId;
Expand Down Expand Up @@ -704,9 +690,7 @@ TEST(Meta, quad_bulk_nat_entry)

// create

sai_nat_entry_t e[2];

memset(e, 0, sizeof(e));
sai_nat_entry_t e[2] = {};

e[0].switch_id = switchId;
e[1].switch_id = switchId;
Expand Down Expand Up @@ -846,9 +830,7 @@ TEST(Meta, quad_bulk_my_sid_entry)

// create

sai_my_sid_entry_t e[2];

memset(e, 0, sizeof(e));
sai_my_sid_entry_t e[2] = {};

e[0].switch_id = switchId;
e[1].switch_id = switchId;
Expand Down Expand Up @@ -927,9 +909,7 @@ TEST(Meta, quad_bulk_inseg_entry)

// create

sai_inseg_entry_t e[2];

memset(e, 0, sizeof(e));
sai_inseg_entry_t e[2] = {};

e[0].switch_id = switchId;
e[1].switch_id = switchId;
Expand Down
Loading