From 8f13f8ef2463d8d14d13509d2b44a9b69b794b69 Mon Sep 17 00:00:00 2001 From: Kamil Cudnik Date: Thu, 27 Jul 2017 10:43:58 -0700 Subject: [PATCH] [Make]: Fix type conversions and add more warnings (#267) --- configure.ac | 34 ++++++++++++++++++++++ fpmsyncd/fpmlink.cpp | 4 +-- orchagent/aclorch.cpp | 31 ++++++++++---------- orchagent/bufferorch.cpp | 20 ++++++------- orchagent/copporch.cpp | 10 +++---- orchagent/fdborch.cpp | 2 +- orchagent/intfsorch.cpp | 6 ++-- orchagent/main.cpp | 4 +-- orchagent/mirrororch.cpp | 4 +-- orchagent/neighorch.cpp | 2 +- orchagent/orch.cpp | 6 ++-- orchagent/port.cpp | 7 ++--- orchagent/portsorch.cpp | 28 +++++++++--------- orchagent/qosorch.cpp | 54 +++++++++++++++++------------------ orchagent/routeorch.cpp | 4 +-- orchagent/saihelper.cpp | 8 +++--- orchagent/tunneldecaporch.cpp | 6 ++-- 17 files changed, 131 insertions(+), 99 deletions(-) diff --git a/configure.ac b/configure.ac index 301b4edd2c63..145a0a1d6ad4 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,40 @@ AM_CONDITIONAL(GTEST, test x$gtest = xtrue) CFLAGS_COMMON="-std=c++11 -Wall -fPIC -Wno-write-strings -I/usr/include/libnl3 -I/usr/include/swss" CFLAGS_COMMON+=" -Werror" CFLAGS_COMMON+=" -Wno-reorder" +CFLAGS_COMMON+=" -Wcast-align" +CFLAGS_COMMON+=" -Wcast-qual" +CFLAGS_COMMON+=" -Wconversion" +CFLAGS_COMMON+=" -Wdisabled-optimization" +CFLAGS_COMMON+=" -Wextra" +CFLAGS_COMMON+=" -Wfloat-equal" +CFLAGS_COMMON+=" -Wformat=2" +CFLAGS_COMMON+=" -Wformat-nonliteral" +CFLAGS_COMMON+=" -Wformat-security" +CFLAGS_COMMON+=" -Wformat-y2k" +CFLAGS_COMMON+=" -Wimport" +CFLAGS_COMMON+=" -Winit-self" +CFLAGS_COMMON+=" -Winvalid-pch" +CFLAGS_COMMON+=" -Wlong-long" +CFLAGS_COMMON+=" -Wmissing-field-initializers" +CFLAGS_COMMON+=" -Wmissing-format-attribute" +CFLAGS_COMMON+=" -Wno-aggregate-return" +CFLAGS_COMMON+=" -Wno-padded" +CFLAGS_COMMON+=" -Wno-switch-enum" +CFLAGS_COMMON+=" -Wno-unused-parameter" +CFLAGS_COMMON+=" -Wpacked" +CFLAGS_COMMON+=" -Wpointer-arith" +CFLAGS_COMMON+=" -Wredundant-decls" +CFLAGS_COMMON+=" -Wstack-protector" +CFLAGS_COMMON+=" -Wstrict-aliasing=3" +CFLAGS_COMMON+=" -Wswitch" +CFLAGS_COMMON+=" -Wswitch-default" +CFLAGS_COMMON+=" -Wunreachable-code" +CFLAGS_COMMON+=" -Wunused" +CFLAGS_COMMON+=" -Wvariadic-macros" +CFLAGS_COMMON+=" -Wno-switch-default" +CFLAGS_COMMON+=" -Wno-long-long" +CFLAGS_COMMON+=" -Wno-redundant-decls" + AC_SUBST(CFLAGS_COMMON) AC_CONFIG_FILES([ diff --git a/fpmsyncd/fpmlink.cpp b/fpmsyncd/fpmlink.cpp index ad142c7c8449..9dfedb6c1b64 100644 --- a/fpmsyncd/fpmlink.cpp +++ b/fpmsyncd/fpmlink.cpp @@ -109,7 +109,7 @@ void FpmLink::readMe() throw FpmConnectionClosedException(); if (read < 0) throw system_error(errno, system_category()); - m_pos+= read; + m_pos+= (uint32_t)read; /* Check for complete messages */ while (true) @@ -140,5 +140,5 @@ void FpmLink::readMe() } memmove(m_messageBuffer, m_messageBuffer + start, m_pos - start); - m_pos = m_pos - start; + m_pos = m_pos - (uint32_t)start; } diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index 988fa63fc5dc..6bc29d28d234 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -109,7 +109,7 @@ bool AclRule::validateAddPriority(string attr_name, string attr_value) { char *endp = NULL; errno = 0; - m_priority = strtol(attr_value.c_str(), &endp, 0); + m_priority = (uint32_t)strtol(attr_value.c_str(), &endp, 0); // chack conversion was successfull and the value is within the allowed range status = (errno == 0) && (endp == attr_value.c_str() + attr_value.size()) && @@ -161,23 +161,23 @@ bool AclRule::validateAddMatch(string attr_name, string attr_value) flags = trim(flagsData[0]); mask = trim(flagsData[1]); - val = strtol(flags.c_str(), &endp, 0); + val = (uint32_t)strtol(flags.c_str(), &endp, 0); if (errno || (endp != flags.c_str() + flags.size()) || (val < 0) || (val > UCHAR_MAX)) { SWSS_LOG_ERROR("TCP flags parse error, value: %s(=%d), errno: %d", flags.c_str(), val, errno); return false; } - value.aclfield.data.u8 = val; + value.aclfield.data.u8 = (uint8_t)val; - val = strtol(mask.c_str(), &endp, 0); + val = (uint32_t)strtol(mask.c_str(), &endp, 0); if (errno || (endp != mask.c_str() + mask.size()) || (val < 0) || (val > UCHAR_MAX)) { SWSS_LOG_ERROR("TCP mask parse error, value: %s(=%d), errno: %d", mask.c_str(), val, errno); return false; } - value.aclfield.mask.u8 = val; + value.aclfield.mask.u8 = (uint8_t)val; } else if(attr_name == MATCH_ETHER_TYPE || attr_name == MATCH_L4_SRC_PORT || attr_name == MATCH_L4_DST_PORT) { @@ -344,7 +344,7 @@ bool AclRule::create() rule_attrs.push_back(attr); } - status = sai_acl_api->create_acl_entry(&m_ruleOid, gSwitchId, rule_attrs.size(), rule_attrs.data()); + status = sai_acl_api->create_acl_entry(&m_ruleOid, gSwitchId, (uint32_t)rule_attrs.size(), rule_attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create ACL rule"); @@ -483,7 +483,7 @@ bool AclRule::createCounter() attr.value.booldata = true; counter_attrs.push_back(attr); - if (sai_acl_api->create_acl_counter(&m_counterOid, gSwitchId, counter_attrs.size(), counter_attrs.data()) != SAI_STATUS_SUCCESS) + if (sai_acl_api->create_acl_counter(&m_counterOid, gSwitchId, (uint32_t)counter_attrs.size(), counter_attrs.data()) != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create counter for the rule %s in table %s", m_id.c_str(), m_tableId.c_str()); return false; @@ -891,7 +891,7 @@ AclRange *AclRange::create(sai_acl_range_type_t type, int min, int max) attr.value.u32range.max = max; range_attrs.push_back(attr); - status = sai_acl_api->create_acl_range(&range_oid, gSwitchId, range_attrs.size(), range_attrs.data()); + status = sai_acl_api->create_acl_range(&range_oid, gSwitchId, (uint32_t)range_attrs.size(), range_attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create range object"); @@ -985,14 +985,13 @@ AclOrch::AclOrch(DBConnector *db, vector tableNames, PortsOrch *portOrch { SWSS_LOG_ENTER(); - sai_attribute_t attrs[] = - { - { SAI_SWITCH_ATTR_ACL_ENTRY_MINIMUM_PRIORITY }, - { SAI_SWITCH_ATTR_ACL_ENTRY_MAXIMUM_PRIORITY } - }; + sai_attribute_t attrs[2]; + + attrs[0].id = SAI_SWITCH_ATTR_ACL_ENTRY_MINIMUM_PRIORITY; + attrs[1].id = SAI_SWITCH_ATTR_ACL_ENTRY_MAXIMUM_PRIORITY; // get min/max allowed priority - if (sai_switch_api->get_switch_attribute(gSwitchId, sizeof(attrs)/sizeof(attrs[0]), attrs) == SAI_STATUS_SUCCESS) + if (sai_switch_api->get_switch_attribute(gSwitchId, 2, attrs) == SAI_STATUS_SUCCESS) { SWSS_LOG_INFO("Got ACL entry priority values, min: %u, max: %u", attrs[0].value.u32, attrs[1].value.u32); AclRule::setRulePriorities(attrs[0].value.u32, attrs[1].value.u32); @@ -1454,11 +1453,11 @@ sai_status_t AclOrch::createBindAclTable(AclTable &aclTable, sai_object_id_t &ta } attr.id = SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE; - attr.value.s32list.count = sizeof(range_types_list) / sizeof(range_types_list[0]); + attr.value.s32list.count = (uint32_t)(sizeof(range_types_list) / sizeof(range_types_list[0])); attr.value.s32list.list = range_types_list; table_attrs.push_back(attr); - status = sai_acl_api->create_acl_table(&table_oid, gSwitchId, table_attrs.size(), table_attrs.data()); + status = sai_acl_api->create_acl_table(&table_oid, gSwitchId, (uint32_t)table_attrs.size(), table_attrs.data()); if (status == SAI_STATUS_SUCCESS) { diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 01f46f3e2624..121de6303a78 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -70,7 +70,7 @@ task_process_status BufferOrch::processBufferPool(Consumer &consumer) if (fvField(*i) == buffer_size_field_name) { attr.id = SAI_BUFFER_POOL_ATTR_SIZE; - attr.value.u32 = stoul(fvValue(*i)); + attr.value.u32 = (uint32_t)stoul(fvValue(*i)); attribs.push_back(attr); } else if (fvField(*i) == buffer_pool_type_field_name) @@ -129,7 +129,7 @@ task_process_status BufferOrch::processBufferPool(Consumer &consumer) } else { - sai_status = sai_buffer_api->create_buffer_pool(&sai_object, gSwitchId, attribs.size(), attribs.data()); + sai_status = sai_buffer_api->create_buffer_pool(&sai_object, gSwitchId, (uint32_t)attribs.size(), attribs.data()); if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to create buffer pool %s with type %s, rv:%d", object_name.c_str(), map_type_name.c_str(), sai_status); @@ -204,32 +204,32 @@ task_process_status BufferOrch::processBufferProfile(Consumer &consumer) } else if (fvField(*i) == buffer_xon_field_name) { - attr.value.u32 = stoul(fvValue(*i)); + attr.value.u32 = (uint32_t)stoul(fvValue(*i)); attr.id = SAI_BUFFER_PROFILE_ATTR_XON_TH; attribs.push_back(attr); } else if (fvField(*i) == buffer_xoff_field_name) { - attr.value.u32 = stoul(fvValue(*i)); + attr.value.u32 = (uint32_t)stoul(fvValue(*i)); attr.id = SAI_BUFFER_PROFILE_ATTR_XOFF_TH; attribs.push_back(attr); } else if (fvField(*i) == buffer_size_field_name) { attr.id = SAI_BUFFER_PROFILE_ATTR_BUFFER_SIZE; - attr.value.u32 = stoul(fvValue(*i)); + attr.value.u32 = (uint32_t)stoul(fvValue(*i)); attribs.push_back(attr); } else if (fvField(*i) == buffer_dynamic_th_field_name) { attr.id = SAI_BUFFER_PROFILE_ATTR_SHARED_DYNAMIC_TH; - attr.value.u32 = stoul(fvValue(*i)); + attr.value.u32 = (uint32_t)stoul(fvValue(*i)); attribs.push_back(attr); } else if (fvField(*i) == buffer_static_th_field_name) { attr.id = SAI_BUFFER_PROFILE_ATTR_SHARED_STATIC_TH; - attr.value.u32 = stoul(fvValue(*i)); + attr.value.u32 = (uint32_t)stoul(fvValue(*i)); attribs.push_back(attr); } else @@ -250,7 +250,7 @@ task_process_status BufferOrch::processBufferProfile(Consumer &consumer) } else { - sai_status = sai_buffer_api->create_buffer_profile(&sai_object, gSwitchId, attribs.size(), attribs.data()); + sai_status = sai_buffer_api->create_buffer_profile(&sai_object, gSwitchId, (uint32_t)attribs.size(), attribs.data()); if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to create buffer profile %s with type %s, rv:%d", object_name.c_str(), map_type_name.c_str(), sai_status); @@ -456,7 +456,7 @@ task_process_status BufferOrch::processIngressBufferProfileList(Consumer &consum } sai_attribute_t attr; attr.id = SAI_PORT_ATTR_QOS_INGRESS_BUFFER_PROFILE_LIST; - attr.value.objlist.count = profile_list.size(); + attr.value.objlist.count = (uint32_t)profile_list.size(); attr.value.objlist.list = profile_list.data(); for (string port_name : port_names) { @@ -502,7 +502,7 @@ task_process_status BufferOrch::processEgressBufferProfileList(Consumer &consume } sai_attribute_t attr; attr.id = SAI_PORT_ATTR_QOS_EGRESS_BUFFER_PROFILE_LIST; - attr.value.objlist.count = profile_list.size(); + attr.value.objlist.count = (uint32_t)profile_list.size(); attr.value.objlist.list = profile_list.data(); for (string port_name : port_names) { diff --git a/orchagent/copporch.cpp b/orchagent/copporch.cpp index f49a07fd5cde..bf9ff4daab9c 100644 --- a/orchagent/copporch.cpp +++ b/orchagent/copporch.cpp @@ -109,7 +109,7 @@ void CoppOrch::initDefaultHostTable() sai_if_channel_attrs.push_back(sai_if_channel_attr); sai_status_t status = sai_hostif_api->create_hostif_table_entry( - &host_table_entry[0], gSwitchId, sai_if_channel_attrs.size(), sai_if_channel_attrs.data()); + &host_table_entry[0], gSwitchId, (uint32_t)sai_if_channel_attrs.size(), sai_if_channel_attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create hostif table entry, rc=%d", status); @@ -189,7 +189,7 @@ bool CoppOrch::applyAttributesToTrapIds(sai_object_id_t trap_group_id, attrs.insert(attrs.end(), trap_id_attribs.begin(), trap_id_attribs.end()); sai_object_id_t hostif_trap_id; - status = sai_hostif_api->create_hostif_trap(&hostif_trap_id, gSwitchId, attrs.size(), attrs.data()); + status = sai_hostif_api->create_hostif_trap(&hostif_trap_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create trap %d, rc=%d", trap_id, status); @@ -300,7 +300,7 @@ bool CoppOrch::createPolicer(string trap_group_name, vector &po sai_object_id_t policer_id; sai_status_t sai_status; - sai_status = sai_policer_api->create_policer(&policer_id, gSwitchId, policer_attribs.size(), policer_attribs.data()); + sai_status = sai_policer_api->create_policer(&policer_id, gSwitchId, (uint32_t)policer_attribs.size(), policer_attribs.data()); if (sai_status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create policer trap group %s, rc=%d", trap_group_name.c_str(), sai_status); @@ -356,7 +356,7 @@ task_process_status CoppOrch::processCoppRule(Consumer& consumer) queue_ind = fvValue(*i); SWSS_LOG_DEBUG("queue data:%s", queue_ind.c_str()); attr.id = SAI_HOSTIF_TRAP_GROUP_ATTR_QUEUE; - attr.value.u32 = stoul(queue_ind); + attr.value.u32 = (uint32_t)stoul(queue_ind); trap_gr_attribs.push_back(attr); } // @@ -507,7 +507,7 @@ task_process_status CoppOrch::processCoppRule(Consumer& consumer) { sai_object_id_t new_trap; - sai_status = sai_hostif_api->create_hostif_trap_group(&new_trap, gSwitchId, trap_gr_attribs.size(), trap_gr_attribs.data()); + sai_status = sai_hostif_api->create_hostif_trap_group(&new_trap, gSwitchId, (uint32_t)trap_gr_attribs.size(), trap_gr_attribs.data()); if (sai_status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create host interface trap group %s, rc=%d", trap_group_name.c_str(), sai_status); diff --git a/orchagent/fdborch.cpp b/orchagent/fdborch.cpp index 767f76abb8fc..764f656c3c7d 100644 --- a/orchagent/fdborch.cpp +++ b/orchagent/fdborch.cpp @@ -207,7 +207,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name, const attr.value.s32 = SAI_PACKET_ACTION_FORWARD; attrs.push_back(attr); - status = sai_fdb_api->create_fdb_entry(&fdb_entry, attrs.size(), attrs.data()); + status = sai_fdb_api->create_fdb_entry(&fdb_entry, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to add FDB entry. mac=%s, vlan=%d. port_name %s. type %s", diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index d2cb37a3ece0..7cf44ccd6d44 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -254,7 +254,7 @@ bool IntfsOrch::addRouterIntfs(Port &port) } attrs.push_back(attr); - sai_status_t status = sai_router_intfs_api->create_router_interface(&port.m_rif_id, gSwitchId, attrs.size(), attrs.data()); + sai_status_t status = sai_router_intfs_api->create_router_interface(&port.m_rif_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create router interface for port %s, rv:%d", port.m_alias.c_str(), status); @@ -312,7 +312,7 @@ void IntfsOrch::addSubnetRoute(const Port &port, const IpPrefix &ip_prefix) attr.value.oid = port.m_rif_id; attrs.push_back(attr); - sai_status_t status = sai_route_api->create_route_entry(&unicast_route_entry, attrs.size(), attrs.data()); + sai_status_t status = sai_route_api->create_route_entry(&unicast_route_entry, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create subnet route to %s from %s, rv:%d", @@ -367,7 +367,7 @@ void IntfsOrch::addIp2MeRoute(const IpPrefix &ip_prefix) attr.value.oid = cpu_port.m_port_id; attrs.push_back(attr); - sai_status_t status = sai_route_api->create_route_entry(&unicast_route_entry, attrs.size(), attrs.data()); + sai_status_t status = sai_route_api->create_route_entry(&unicast_route_entry, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create IP2me route ip:%s, rv:%d", ip_prefix.getIp().to_string().c_str(), status); diff --git a/orchagent/main.cpp b/orchagent/main.cpp index d9a4264fcf0f..6111af964249 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -175,7 +175,7 @@ int main(int argc, char **argv) attrs.push_back(attr); } - status = sai_switch_api->create_switch(&gSwitchId, attrs.size(), attrs.data()); + status = sai_switch_api->create_switch(&gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create a switch, rv:%d", status); @@ -224,7 +224,7 @@ int main(int argc, char **argv) underlay_intf_attr.value.s32 = SAI_ROUTER_INTERFACE_TYPE_LOOPBACK; underlay_intf_attrs.push_back(underlay_intf_attr); - status = sai_router_intfs_api->create_router_interface(&gUnderlayIfId, gSwitchId, underlay_intf_attrs.size(), underlay_intf_attrs.data()); + status = sai_router_intfs_api->create_router_interface(&gUnderlayIfId, gSwitchId, (uint32_t)underlay_intf_attrs.size(), underlay_intf_attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create underlay router interface %d", status); diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index 22d569a27001..44ad72d2e956 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -423,7 +423,7 @@ bool MirrorOrch::activateSession(const string& name, MirrorEntry& session) // TOS value format is the following: // DSCP 6 bits | ECN 2 bits attr.id =SAI_MIRROR_SESSION_ATTR_TOS; - attr.value.u16 = session.dscp << MIRROR_SESSION_DSCP_SHIFT; + attr.value.u16 = (uint16_t)(session.dscp << MIRROR_SESSION_DSCP_SHIFT); attrs.push_back(attr); attr.id =SAI_MIRROR_SESSION_ATTR_TTL; @@ -452,7 +452,7 @@ bool MirrorOrch::activateSession(const string& name, MirrorEntry& session) session.status = true; - status = sai_mirror_api->create_mirror_session(&session.sessionId, gSwitchId, attrs.size(), attrs.data()); + status = sai_mirror_api->create_mirror_session(&session.sessionId, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to activate mirroring session %s\n", name.c_str()); diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index ecaf6d5804a1..5cccf322eabb 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -43,7 +43,7 @@ bool NeighOrch::addNextHop(IpAddress ipAddress, string alias) next_hop_attrs.push_back(next_hop_attr); sai_object_id_t next_hop_id; - sai_status_t status = sai_next_hop_api->create_next_hop(&next_hop_id, gSwitchId, next_hop_attrs.size(), next_hop_attrs.data()); + sai_status_t status = sai_next_hop_api->create_next_hop(&next_hop_id, gSwitchId, (uint32_t)next_hop_attrs.size(), next_hop_attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create next hop %s on %s, rv:%d", diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 82b9ac361f84..fcb29aceaa26 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -336,8 +336,8 @@ bool Orch::parseIndexRange(const string &input, sai_uint32_t &range_low, sai_uin SWSS_LOG_ERROR("malformed index range in:%s. Must contain 2 tokens\n", input.c_str()); return false; } - range_low = stoul(range_values[0]); - range_high = stoul(range_values[1]); + range_low = (uint32_t)stoul(range_values[0]); + range_high = (uint32_t)stoul(range_values[1]); if (range_low >= range_high) { SWSS_LOG_ERROR("malformed index range in:%s. left value must be less than righ value.\n", input.c_str()); @@ -346,7 +346,7 @@ bool Orch::parseIndexRange(const string &input, sai_uint32_t &range_low, sai_uin } else { - range_low = range_high = stoul(input); + range_low = range_high = (uint32_t)stoul(input); } SWSS_LOG_DEBUG("resulting range:%d-%d", range_low, range_high); return true; diff --git a/orchagent/port.cpp b/orchagent/port.cpp index 514cd5829629..90f66e90eed7 100644 --- a/orchagent/port.cpp +++ b/orchagent/port.cpp @@ -41,7 +41,7 @@ sai_status_t Port::bindAclTable(sai_object_id_t& group_member_oid, sai_object_id group_attr.value.s32 = SAI_ACL_TABLE_GROUP_TYPE_PARALLEL; group_attrs.push_back(group_attr); - status = sai_acl_api->create_acl_table_group(&groupOid, gSwitchId, group_attrs.size(), group_attrs.data()); + status = sai_acl_api->create_acl_table_group(&groupOid, gSwitchId, (uint32_t)group_attrs.size(), group_attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create ACL table group, rv:%d", status); @@ -86,9 +86,8 @@ sai_status_t Port::bindAclTable(sai_object_id_t& group_member_oid, sai_object_id member_attr.value.u32 = 100; // TODO: double check! member_attrs.push_back(member_attr); - status = sai_acl_api->create_acl_table_group_member(&group_member_oid, gSwitchId, member_attrs.size(), member_attrs.data()); - if (status != SAI_STATUS_SUCCESS) - { + status = sai_acl_api->create_acl_table_group_member(&group_member_oid, gSwitchId, (uint32_t)member_attrs.size(), member_attrs.data()); + if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create member in ACL table group %lx for ACL table group %lx, rv:%d", table_oid, groupOid, status); return status; diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index cc081a5d3056..db708f4bc180 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -84,7 +84,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : port_list.resize(m_portCount); attr.id = SAI_SWITCH_ATTR_PORT_LIST; - attr.value.objlist.count = port_list.size(); + attr.value.objlist.count = (uint32_t)port_list.size(); attr.value.objlist.list = port_list.data(); status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr); @@ -131,7 +131,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : attr.id = SAI_SWITCH_ATTR_DEFAULT_VLAN_ID; attrs.push_back(attr); - status = sai_switch_api->get_switch_attribute(gSwitchId, attrs.size(), attrs.data()); + status = sai_switch_api->get_switch_attribute(gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get default 1Q bridge and/or default VLAN, rv:%d", status); @@ -152,7 +152,7 @@ void PortsOrch::removeDefaultVlanMembers() sai_attribute_t attr; attr.id = SAI_VLAN_ATTR_MEMBER_LIST; - attr.value.objlist.count = vlan_member_list.size(); + attr.value.objlist.count = (uint32_t)vlan_member_list.size(); attr.value.objlist.list = vlan_member_list.data(); sai_status_t status = sai_vlan_api->get_vlan_attribute(m_defaultVlan, 1, &attr); @@ -186,7 +186,7 @@ void PortsOrch::removeDefaultBridgePorts() sai_attribute_t attr; attr.id = SAI_BRIDGE_ATTR_PORT_LIST; - attr.value.objlist.count = bridge_port_list.size(); + attr.value.objlist.count = (uint32_t)bridge_port_list.size(); attr.value.objlist.list = bridge_port_list.data(); sai_status_t status = sai_bridge_api->get_bridge_attribute(m_default1QBridge, 1, &attr); @@ -332,7 +332,7 @@ bool PortsOrch::setPortMtu(sai_object_id_t id, sai_uint32_t mtu) sai_attribute_t attr; attr.id = SAI_PORT_ATTR_MTU; /* mtu + 14 + 4 + 4 = 22 bytes */ - attr.value.u32 = mtu + sizeof(struct ether_header) + FCS_LEN + VLAN_TAG_LEN; + attr.value.u32 = (uint32_t)(mtu + sizeof(struct ether_header) + FCS_LEN + VLAN_TAG_LEN); sai_status_t status = sai_port_api->set_port_attribute(id, &attr); if (status != SAI_STATUS_SUCCESS) @@ -448,7 +448,7 @@ void PortsOrch::doPortTask(Consumer &consumer) /* Set port mtu */ if (fvField(i) == "mtu") - mtu = stoul(fvValue(i)); + mtu = (uint32_t)stoul(fvValue(i)); } if (lane_set.size()) @@ -468,7 +468,7 @@ void PortsOrch::doPortTask(Consumer &consumer) { Port p(alias, Port::PHY); - p.m_index = m_portList.size(); // TODO: Assume no deletion of physical port + p.m_index = (uint32_t)m_portList.size(); // TODO: Assume no deletion of physical port p.m_port_id = id; /* Initialize the port and create router interface and host interface */ @@ -911,7 +911,7 @@ void PortsOrch::initializeQueues(Port &port) } attr.id = SAI_PORT_ATTR_QOS_QUEUE_LIST; - attr.value.objlist.count = port.m_queue_ids.size(); + attr.value.objlist.count = (uint32_t)port.m_queue_ids.size(); attr.value.objlist.list = port.m_queue_ids.data(); status = sai_port_api->get_port_attribute(port.m_port_id, 1, &attr); @@ -945,7 +945,7 @@ void PortsOrch::initializePriorityGroups(Port &port) } attr.id = SAI_PORT_ATTR_INGRESS_PRIORITY_GROUP_LIST; - attr.value.objlist.count = port.m_priority_group_ids.size(); + attr.value.objlist.count = (uint32_t)port.m_priority_group_ids.size(); attr.value.objlist.list = port.m_priority_group_ids.data(); status = sai_port_api->get_port_attribute(port.m_port_id, 1, &attr); @@ -1014,7 +1014,7 @@ bool PortsOrch::addHostIntfs(sai_object_id_t id, string alias, sai_object_id_t & strncpy((char *)&attr.value.chardata, alias.c_str(), HOSTIF_NAME_SIZE); attrs.push_back(attr); - sai_status_t status = sai_hostif_api->create_hostif(&host_intfs_id, gSwitchId, attrs.size(), attrs.data()); + sai_status_t status = sai_hostif_api->create_hostif(&host_intfs_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create host interface for port %s", alias.c_str()); @@ -1046,7 +1046,7 @@ bool PortsOrch::addBridgePort(Port &port) attr.value.booldata = true; attrs.push_back(attr); - sai_status_t status = sai_bridge_api->create_bridge_port(&port.m_bridge_port_id, gSwitchId, attrs.size(), attrs.data()); + sai_status_t status = sai_bridge_api->create_bridge_port(&port.m_bridge_port_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to add bridge port %s to default 1Q bridge, rv:%d", @@ -1100,7 +1100,7 @@ bool PortsOrch::addVlan(string vlan_alias) sai_object_id_t vlan_oid; - sai_vlan_id_t vlan_id = stoi(vlan_alias.substr(4)); + sai_vlan_id_t vlan_id = (uint16_t)stoi(vlan_alias.substr(4)); sai_attribute_t attr; attr.id = SAI_VLAN_ATTR_VLAN_ID; attr.value.u16 = vlan_id; @@ -1174,7 +1174,7 @@ bool PortsOrch::addVlanMember(Port vlan, Port port, string& tagging_mode) attrs.push_back(attr); sai_object_id_t vlan_member_id; - sai_status_t status = sai_vlan_api->create_vlan_member(&vlan_member_id, gSwitchId, attrs.size(), attrs.data()); + sai_status_t status = sai_vlan_api->create_vlan_member(&vlan_member_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to add member %s to VLAN %s vid:%hu pid:%lx", @@ -1318,7 +1318,7 @@ bool PortsOrch::addLagMember(Port lag, Port port) attrs.push_back(attr); sai_object_id_t lag_member_id; - sai_status_t status = sai_lag_api->create_lag_member(&lag_member_id, gSwitchId, attrs.size(), attrs.data()); + sai_status_t status = sai_lag_api->create_lag_member(&lag_member_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index abb91e0bdda3..4896516d7fbe 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -157,13 +157,13 @@ bool DscpToTcMapHandler::convertFieldValuesToAttributes(KeyOpFieldsValuesTuple & SWSS_LOG_ENTER(); sai_attribute_t list_attr; sai_qos_map_list_t dscp_map_list; - dscp_map_list.count = kfvFieldsValues(tuple).size(); + dscp_map_list.count = (uint32_t)kfvFieldsValues(tuple).size(); dscp_map_list.list = new sai_qos_map_t[dscp_map_list.count](); uint32_t ind = 0; for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++, ind++) { - dscp_map_list.list[ind].key.dscp = stoi(fvField(*i)); - dscp_map_list.list[ind].value.tc = stoi(fvValue(*i)); + dscp_map_list.list[ind].key.dscp = (uint8_t)stoi(fvField(*i)); + dscp_map_list.list[ind].value.tc = (uint8_t)stoi(fvValue(*i)); SWSS_LOG_DEBUG("key.dscp:%d, value.tc:%d", dscp_map_list.list[ind].key.dscp, dscp_map_list.list[ind].value.tc); } list_attr.id = SAI_QOS_MAP_ATTR_MAP_TO_VALUE_LIST; @@ -190,7 +190,7 @@ sai_object_id_t DscpToTcMapHandler::addQosItem(const vector &at qos_map_attr.value.qosmap.list = attributes[0].value.qosmap.list; qos_map_attrs.push_back(qos_map_attr); - sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, qos_map_attrs.size(), qos_map_attrs.data()); + sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, (uint32_t)qos_map_attrs.size(), qos_map_attrs.data()); if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to create dscp_to_tc map. status:%d", sai_status); @@ -212,13 +212,13 @@ bool TcToQueueMapHandler::convertFieldValuesToAttributes(KeyOpFieldsValuesTuple SWSS_LOG_ENTER(); sai_attribute_t list_attr; sai_qos_map_list_t tc_map_list; - tc_map_list.count = kfvFieldsValues(tuple).size(); + tc_map_list.count = (uint32_t)kfvFieldsValues(tuple).size(); tc_map_list.list = new sai_qos_map_t[tc_map_list.count](); uint32_t ind = 0; for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++, ind++) { - tc_map_list.list[ind].key.tc = stoi(fvField(*i)); - tc_map_list.list[ind].value.queue_index = stoi(fvValue(*i)); + tc_map_list.list[ind].key.tc = (uint8_t)stoi(fvField(*i)); + tc_map_list.list[ind].value.queue_index = (uint8_t)stoi(fvValue(*i)); } list_attr.id = SAI_QOS_MAP_ATTR_MAP_TO_VALUE_LIST; list_attr.value.qosmap.count = tc_map_list.count; @@ -244,7 +244,7 @@ sai_object_id_t TcToQueueMapHandler::addQosItem(const vector &a qos_map_attr.value.qosmap.list = attributes[0].value.qosmap.list; qos_map_attrs.push_back(qos_map_attr); - sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, qos_map_attrs.size(), qos_map_attrs.data()); + sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, (uint32_t)qos_map_attrs.size(), qos_map_attrs.data()); if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to create tc_to_queue map. status:%d", sai_status); @@ -406,7 +406,7 @@ sai_object_id_t WredMapHandler::addQosItem(const vector &attrib { attrs.push_back(attrib); } - sai_status = sai_wred_api->create_wred(&sai_object, gSwitchId, attrs.size(), attrs.data()); + sai_status = sai_wred_api->create_wred(&sai_object, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (sai_status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create wred profile: %d", sai_status); @@ -440,13 +440,13 @@ bool TcToPgHandler::convertFieldValuesToAttributes(KeyOpFieldsValuesTuple &tuple SWSS_LOG_ENTER(); sai_attribute_t list_attr; sai_qos_map_list_t tc_to_pg_map_list; - tc_to_pg_map_list.count = kfvFieldsValues(tuple).size(); + tc_to_pg_map_list.count = (uint32_t)kfvFieldsValues(tuple).size(); tc_to_pg_map_list.list = new sai_qos_map_t[tc_to_pg_map_list.count](); uint32_t ind = 0; for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++, ind++) { - tc_to_pg_map_list.list[ind].key.tc = stoi(fvField(*i)); - tc_to_pg_map_list.list[ind].value.pg = stoi(fvValue(*i)); + tc_to_pg_map_list.list[ind].key.tc = (uint8_t)stoi(fvField(*i)); + tc_to_pg_map_list.list[ind].value.pg = (uint8_t)stoi(fvValue(*i)); } list_attr.id = SAI_QOS_MAP_ATTR_MAP_TO_VALUE_LIST; list_attr.value.qosmap.count = tc_to_pg_map_list.count; @@ -471,7 +471,7 @@ sai_object_id_t TcToPgHandler::addQosItem(const vector &attribu qos_map_attr.value.qosmap.list = attributes[0].value.qosmap.list; qos_map_attrs.push_back(qos_map_attr); - sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, qos_map_attrs.size(), qos_map_attrs.data()); + sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, (uint32_t)qos_map_attrs.size(), qos_map_attrs.data()); if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to create tc_to_queue map. status:%d", sai_status); @@ -493,13 +493,13 @@ bool PfcPrioToPgHandler::convertFieldValuesToAttributes(KeyOpFieldsValuesTuple & SWSS_LOG_ENTER(); sai_attribute_t list_attr; sai_qos_map_list_t pfc_prio_to_pg_map_list; - pfc_prio_to_pg_map_list.count = kfvFieldsValues(tuple).size(); + pfc_prio_to_pg_map_list.count = (uint32_t)kfvFieldsValues(tuple).size(); pfc_prio_to_pg_map_list.list = new sai_qos_map_t[pfc_prio_to_pg_map_list.count](); uint32_t ind = 0; for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++, ind++) { - pfc_prio_to_pg_map_list.list[ind].key.prio = stoi(fvField(*i)); - pfc_prio_to_pg_map_list.list[ind].value.pg = stoi(fvValue(*i)); + pfc_prio_to_pg_map_list.list[ind].key.prio = (uint8_t)stoi(fvField(*i)); + pfc_prio_to_pg_map_list.list[ind].value.pg = (uint8_t)stoi(fvValue(*i)); } list_attr.id = SAI_QOS_MAP_ATTR_MAP_TO_VALUE_LIST; list_attr.value.qosmap.count = pfc_prio_to_pg_map_list.count; @@ -525,7 +525,7 @@ sai_object_id_t PfcPrioToPgHandler::addQosItem(const vector &at qos_map_attr.value.qosmap.list = attributes[0].value.qosmap.list; qos_map_attrs.push_back(qos_map_attr); - sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, qos_map_attrs.size(), qos_map_attrs.data()); + sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, (uint32_t)qos_map_attrs.size(), qos_map_attrs.data()); if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to create tc_to_queue map. status:%d", sai_status); @@ -547,13 +547,13 @@ bool PfcToQueueHandler::convertFieldValuesToAttributes(KeyOpFieldsValuesTuple &t SWSS_LOG_ENTER(); sai_attribute_t list_attr; sai_qos_map_list_t pfc_to_queue_map_list; - pfc_to_queue_map_list.count = kfvFieldsValues(tuple).size(); + pfc_to_queue_map_list.count = (uint32_t)kfvFieldsValues(tuple).size(); pfc_to_queue_map_list.list = new sai_qos_map_t[pfc_to_queue_map_list.count](); uint32_t ind = 0; for (auto i = kfvFieldsValues(tuple).begin(); i != kfvFieldsValues(tuple).end(); i++, ind++) { - pfc_to_queue_map_list.list[ind].key.prio = stoi(fvField(*i)); - pfc_to_queue_map_list.list[ind].value.queue_index = stoi(fvValue(*i)); + pfc_to_queue_map_list.list[ind].key.prio = (uint8_t)stoi(fvField(*i)); + pfc_to_queue_map_list.list[ind].value.queue_index = (uint8_t)stoi(fvValue(*i)); } list_attr.id = SAI_QOS_MAP_ATTR_MAP_TO_VALUE_LIST; list_attr.value.qosmap.count = pfc_to_queue_map_list.count; @@ -580,7 +580,7 @@ sai_object_id_t PfcToQueueHandler::addQosItem(const vector &att qos_map_attr.value.qosmap.list = attributes[0].value.qosmap.list; qos_map_attrs.push_back(qos_map_attr); - sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, qos_map_attrs.size(), qos_map_attrs.data()); + sai_status = sai_qos_map_api->create_qos_map(&sai_object, gSwitchId, (uint32_t)qos_map_attrs.size(), qos_map_attrs.data()); if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to create tc_to_queue map. status:%d", sai_status); @@ -670,7 +670,7 @@ sai_object_id_t QosOrch::initSystemAclTable() attr.value.booldata = true; attrs.push_back(attr); - status = sai_acl_api->create_acl_table(&acl_table_id, gSwitchId, attrs.size(), attrs.data()); + status = sai_acl_api->create_acl_table(&acl_table_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create a system ACL table for ECN coloring, rv:%d", status); @@ -733,7 +733,7 @@ void QosOrch::initAclEntryForEcn(sai_object_id_t acl_table_id, sai_uint32_t prio attr.value.aclaction.parameter.s32 = color; attrs.push_back(attr); - status = sai_acl_api->create_acl_entry(&acl_entry_id, gSwitchId, attrs.size(), attrs.data()); + status = sai_acl_api->create_acl_entry(&acl_entry_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create a system ACL entry for ECN coloring, rv=%d", status); @@ -808,7 +808,7 @@ task_process_status QosOrch::handleSchedulerTable(Consumer& consumer) else if (fvField(*i) == scheduler_weight_field_name) { attr.id = SAI_SCHEDULER_ATTR_SCHEDULING_WEIGHT; - attr.value.u8 = stoi(fvValue(*i)); + attr.value.u8 = (uint8_t)stoi(fvValue(*i)); sai_attr_list.push_back(attr); } else if (fvField(*i) == scheduler_priority_field_name) @@ -836,7 +836,7 @@ task_process_status QosOrch::handleSchedulerTable(Consumer& consumer) } else { - sai_status = sai_scheduler_api->create_scheduler(&sai_object, gSwitchId, sai_attr_list.size(), sai_attr_list.data()); + sai_status = sai_scheduler_api->create_scheduler(&sai_object, gSwitchId, (uint32_t)sai_attr_list.size(), sai_attr_list.data()); if (sai_status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create scheduler profile [%s:%s], rv:%d", @@ -1218,8 +1218,8 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer) queue_indexes = tokenize(fvValue(*it), list_item_delimiter); for(string q_ind : queue_indexes) { - sai_uint8_t q_val = stoi(q_ind); - pfc_enable |= (1 << q_val); + sai_uint8_t q_val = (uint8_t)stoi(q_ind); + pfc_enable |= (uint8_t)(1 << q_val); } } } diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index d7845994b3e2..41d6e7b4aa8b 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -451,7 +451,7 @@ bool RouteOrch::addNextHopGroup(IpAddresses ipAddresses) sai_object_id_t next_hop_group_id; sai_status_t status = sai_next_hop_group_api-> - create_next_hop_group(&next_hop_group_id, gSwitchId, nhg_attrs.size(), nhg_attrs.data()); + create_next_hop_group(&next_hop_group_id, gSwitchId, (uint32_t)nhg_attrs.size(), nhg_attrs.data()); if (status != SAI_STATUS_SUCCESS) { @@ -482,7 +482,7 @@ bool RouteOrch::addNextHopGroup(IpAddresses ipAddresses) sai_object_id_t next_hop_group_member_id; status = sai_next_hop_group_api-> - create_next_hop_group_member(&next_hop_group_member_id, gSwitchId, nhgm_attrs.size(), nhgm_attrs.data()); + create_next_hop_group_member(&next_hop_group_member_id, gSwitchId, (uint32_t)nhgm_attrs.size(), nhgm_attrs.data()); if (status != SAI_STATUS_SUCCESS) { diff --git a/orchagent/saihelper.cpp b/orchagent/saihelper.cpp index f6a0b3f526df..be3ebb46bc34 100644 --- a/orchagent/saihelper.cpp +++ b/orchagent/saihelper.cpp @@ -101,7 +101,7 @@ void initSaiApi() { SWSS_LOG_ENTER(); - sai_api_initialize(0, (service_method_table_t *)&test_services); + sai_api_initialize(0, (const service_method_table_t *)&test_services); sai_api_query(SAI_API_SWITCH, (void **)&sai_switch_api); sai_api_query(SAI_API_BRIDGE, (void **)&sai_bridge_api); @@ -188,8 +188,8 @@ void initSaiRedis(const string &record_location) if (gSairedisRecord) { attr.id = SAI_REDIS_SWITCH_ATTR_RECORDING_OUTPUT_DIR; - attr.value.s8list.count = record_location.size(); - attr.value.s8list.list = (signed char *) record_location.c_str(); + attr.value.s8list.count = (uint32_t)record_location.size(); + attr.value.s8list.list = (int8_t*)const_cast(record_location.c_str()); status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); if (status != SAI_STATUS_SUCCESS) @@ -234,4 +234,4 @@ void initSaiRedis(const string &record_location) } SWSS_LOG_NOTICE("Notify syncd INIT_VIEW"); -} \ No newline at end of file +} diff --git a/orchagent/tunneldecaporch.cpp b/orchagent/tunneldecaporch.cpp index 67b3b7384be3..88c114eaa334 100644 --- a/orchagent/tunneldecaporch.cpp +++ b/orchagent/tunneldecaporch.cpp @@ -204,7 +204,7 @@ bool TunnelDecapOrch::addDecapTunnel(string key, string type, IpAddresses dst_ip overlay_intf_attr.value.s32 = SAI_ROUTER_INTERFACE_TYPE_LOOPBACK; overlay_intf_attrs.push_back(overlay_intf_attr); - status = sai_router_intfs_api->create_router_interface(&overlayIfId, gSwitchId, overlay_intf_attrs.size(), overlay_intf_attrs.data()); + status = sai_router_intfs_api->create_router_interface(&overlayIfId, gSwitchId, (uint32_t)overlay_intf_attrs.size(), overlay_intf_attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create overlay router interface %d", status); @@ -267,7 +267,7 @@ bool TunnelDecapOrch::addDecapTunnel(string key, string type, IpAddresses dst_ip // write attributes to ASIC_DB sai_object_id_t tunnel_id; - status = sai_tunnel_api->create_tunnel(&tunnel_id, gSwitchId, tunnel_attrs.size(), tunnel_attrs.data()); + status = sai_tunnel_api->create_tunnel(&tunnel_id, gSwitchId, (uint32_t)tunnel_attrs.size(), tunnel_attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create tunnel"); @@ -344,7 +344,7 @@ bool TunnelDecapOrch::addDecapTunnelTermEntries(string tunnelKey, IpAddresses ds // create the tunnel table entry sai_object_id_t tunnel_term_table_entry_id; - sai_status_t status = sai_tunnel_api->create_tunnel_term_table_entry(&tunnel_term_table_entry_id, gSwitchId, tunnel_table_entry_attrs.size(), tunnel_table_entry_attrs.data()); + sai_status_t status = sai_tunnel_api->create_tunnel_term_table_entry(&tunnel_term_table_entry_id, gSwitchId, (uint32_t)tunnel_table_entry_attrs.size(), tunnel_table_entry_attrs.data()); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to create tunnel entry table for ip: %s", ip.c_str());