From 6bc64eedf16e0dd377374e3c81ff179f996d459d Mon Sep 17 00:00:00 2001 From: "arheneus@marvell.com" <51254330+antony-rheneus@users.noreply.github.com> Date: Thu, 8 Aug 2019 20:54:19 +0530 Subject: [PATCH] ARM32 bit fixes, for 64bit printf format specifier (#490) * ARM32 bit fixes, for 64bit printf format specifier Signed-off-by: Antony Rheneus * [Warning] -Wlong-long is valid for ULL const in Arm32bit pointer cast align warnings Signed-off-by: Antony Rheneus * Warning fixes for using ULL and pointer type casting in 32 bit arch Signed-off-by: Antony Rheneus * deserialized value didnt match, reverting the warning fix Signed-off-by: Antony Rheneus * Fix for deserialized value not matching after warning changes Signed-off-by: Antony Rheneus * Put back the reverted fix Signed-off-by: Antony Rheneus --- configure.ac | 2 -- meta/Makefile.am | 1 - meta/saiserialize.cpp | 2 +- meta/tests.cpp | 11 +++++----- saidump/saidump.cpp | 3 ++- saiplayer/saiplayer.cpp | 3 ++- syncd/syncd.cpp | 31 +++++++++++++++-------------- syncd/syncd_applyview.cpp | 19 +++++++++--------- syncd/syncd_flex_counter.cpp | 27 +++++++++++++------------ syncd/syncd_notifications.cpp | 15 +++++++------- vslib/src/sai_vs_generic_remove.cpp | 3 ++- vslib/src/sai_vs_hostintf.cpp | 7 +++---- vslib/src/sai_vs_interfacequery.cpp | 3 ++- 13 files changed, 66 insertions(+), 61 deletions(-) diff --git a/configure.ac b/configure.ac index c1b76c03d63d..bf0d7d68f25b 100644 --- a/configure.ac +++ b/configure.ac @@ -72,7 +72,6 @@ CFLAGS_COMMON+=" -Wimport" CFLAGS_COMMON+=" -Winit-self" CFLAGS_COMMON+=" -Winline" CFLAGS_COMMON+=" -Winvalid-pch" -CFLAGS_COMMON+=" -Wlong-long" CFLAGS_COMMON+=" -Wmissing-field-initializers" CFLAGS_COMMON+=" -Wmissing-format-attribute" CFLAGS_COMMON+=" -Wmissing-include-dirs" @@ -95,7 +94,6 @@ CFLAGS_COMMON+=" -Wvariadic-macros" CFLAGS_COMMON+=" -Wwrite-strings" CFLAGS_COMMON+=" -Wno-switch-default" CFLAGS_COMMON+=" -Wconversion" -CFLAGS_COMMON+=" -Wlong-long" AC_SUBST(CFLAGS_COMMON) diff --git a/meta/Makefile.am b/meta/Makefile.am index a99243207317..6907ca80ca47 100644 --- a/meta/Makefile.am +++ b/meta/Makefile.am @@ -28,7 +28,6 @@ WARN = \ -Winit-self \ -Winline \ -Winvalid-pch \ - -Wlong-long \ -Wmissing-field-initializers \ -Wmissing-format-attribute \ -Wmissing-include-dirs \ diff --git a/meta/saiserialize.cpp b/meta/saiserialize.cpp index 7a07640c0896..95eddd86ed70 100644 --- a/meta/saiserialize.cpp +++ b/meta/saiserialize.cpp @@ -2111,7 +2111,7 @@ void sai_deserialize_pointer( { SWSS_LOG_ENTER(); - sai_deserialize_number(s, (uint64_t&)ptr, true); + sai_deserialize_number(s, (uintptr_t &)ptr, true); } void sai_deserialize_ip_address( diff --git a/meta/tests.cpp b/meta/tests.cpp index 6f8daadc288f..a38c79a57262 100644 --- a/meta/tests.cpp +++ b/meta/tests.cpp @@ -2,6 +2,7 @@ #include "sai_extra.h" #include "sai_serialize.h" +#include #include #include @@ -42,7 +43,7 @@ sai_object_type_t sai_object_type_query( if ((objecttype <= SAI_OBJECT_TYPE_NULL) || (objecttype >= SAI_OBJECT_TYPE_EXTENSIONS_MAX)) { - SWSS_LOG_THROW("invalid oid 0x%lx", oid); + SWSS_LOG_THROW("invalid oid 0x%" PRIx64, oid); } return objecttype; @@ -121,7 +122,7 @@ sai_object_id_t create_dummy_object_id( sai_object_id_t oid = construct_object_id(object_type, sw_index, vid_index++); - SWSS_LOG_DEBUG("created oid 0x%lx", oid); + SWSS_LOG_DEBUG("created oid 0x%" PRIx64, oid); return oid; } @@ -3077,7 +3078,7 @@ void test_acl_entry_field_and_action() list[0] = insert_dummy_object(SAI_OBJECT_TYPE_QUEUE,switch_id); - SWSS_LOG_NOTICE("0x%lx", list[0]); + SWSS_LOG_NOTICE("0x%" PRIx64, list[0]); attr.value.aclaction.parameter.objlist.count = 1; attr.value.aclaction.parameter.objlist.list = list; @@ -3426,7 +3427,7 @@ void test_serialize_uint64() s = sai_serialize_attr_value(*meta, attr); char buf[32]; - sprintf(buf, "%lu", attr.value.u64); + sprintf(buf, "%" PRIu64, attr.value.u64); ASSERT_TRUE(s, std::string(buf)); @@ -4016,7 +4017,7 @@ std::string serialize_number( { char buf[32]; - snprintf(buf, sizeof(buf), "0x%lx", (uint64_t)number); + snprintf(buf, sizeof(buf), "0x%" PRIx64, (uint64_t)number); return buf; } diff --git a/saidump/saidump.cpp b/saidump/saidump.cpp index 6cad960e27b0..428638e10046 100644 --- a/saidump/saidump.cpp +++ b/saidump/saidump.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -133,7 +134,7 @@ const TableMap* get_table_map(sai_object_id_t object_id) if (it == g_oid_map.end()) { - SWSS_LOG_THROW("unable to find oid 0x%lx in oid map", object_id); + SWSS_LOG_THROW("unable to find oid 0x%" PRIx64 " in oid map", object_id); } return it->second; diff --git a/saiplayer/saiplayer.cpp b/saiplayer/saiplayer.cpp index 0eb1f6235b8a..edf8c441676e 100644 --- a/saiplayer/saiplayer.cpp +++ b/saiplayer/saiplayer.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -354,7 +355,7 @@ void match_redis_with_rec( if (oid != redis_to_local[get_oid]) { - SWSS_LOG_THROW("match failed, oid order is mismatch :( oid 0x%lx get_oid 0x%lx second 0x%lx", + SWSS_LOG_THROW("match failed, oid order is mismatch :( oid 0x%" PRIx64 " get_oid 0x%" PRIx64 " second 0x%" PRIx64, oid, get_oid, redis_to_local[get_oid]); diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index 00f949c0ab8a..b921a318552a 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -3,6 +3,7 @@ #include "sairedis.h" #include "syncd_flex_counter.h" #include "swss/tokenize.h" +#include #include #include "swss/warm_restart.h" @@ -220,7 +221,7 @@ sai_object_type_t redis_sai_object_type_query( if (!sai_metadata_is_object_type_valid(ot)) { - SWSS_LOG_THROW("invalid object id 0x%lx", object_id); + SWSS_LOG_THROW("invalid object id 0x%" PRIx64, object_id); } return ot; @@ -257,7 +258,7 @@ sai_object_id_t redis_sai_switch_id_query( if (object_type == SAI_OBJECT_TYPE_NULL) { - SWSS_LOG_THROW("invalid object type of oid 0x%lx", oid); + SWSS_LOG_THROW("invalid object type of oid 0x%" PRIx64, oid); } if (object_type == SAI_OBJECT_TYPE_SWITCH) @@ -316,7 +317,7 @@ sai_object_id_t redis_create_virtual_object_id( auto info = sai_metadata_get_object_type_info(object_type); - SWSS_LOG_DEBUG("created virtual object id 0x%lx for object type %s", + SWSS_LOG_DEBUG("created virtual object id 0x%" PRIx64 " for object type %s", vid, info->objecttypename); @@ -393,18 +394,18 @@ sai_object_id_t translate_rid_to_vid( sai_deserialize_object_id(str_vid, vid); - SWSS_LOG_DEBUG("translated RID 0x%lx to VID 0x%lx", rid, vid); + SWSS_LOG_DEBUG("translated RID 0x%" PRIx64 " to VID 0x%" PRIx64, rid, vid); return vid; } - SWSS_LOG_DEBUG("spotted new RID 0x%lx", rid); + SWSS_LOG_DEBUG("spotted new RID 0x%" PRIx64, rid); sai_object_type_t object_type = sai_object_type_query(rid); if (object_type == SAI_OBJECT_TYPE_NULL) { - SWSS_LOG_THROW("sai_object_type_query returned NULL type for RID 0x%lx", rid); + SWSS_LOG_THROW("sai_object_type_query returned NULL type for RID 0x%" PRIx64, rid); } if (object_type == SAI_OBJECT_TYPE_SWITCH) @@ -414,12 +415,12 @@ sai_object_id_t translate_rid_to_vid( * created switch, so we should never get here. */ - SWSS_LOG_THROW("RID 0x%lx is switch object, but not in local or redis db, bug!", rid); + SWSS_LOG_THROW("RID 0x%" PRIx64 " is switch object, but not in local or redis db, bug!", rid); } vid = redis_create_virtual_object_id(switch_vid, object_type); - SWSS_LOG_DEBUG("translated RID 0x%lx to VID 0x%lx", rid, vid); + SWSS_LOG_DEBUG("translated RID 0x%" PRIx64 " to VID 0x%" PRIx64, rid, vid); std::string str_vid = sai_serialize_object_id(vid); @@ -613,7 +614,7 @@ sai_object_id_t translate_vid_to_rid( SWSS_LOG_THROW("can't get RID in init view mode - don't query created objects"); } - SWSS_LOG_THROW("unable to get RID for VID: 0x%lx", vid); + SWSS_LOG_THROW("unable to get RID for VID: 0x%" PRIx64, vid); } str_rid = *prid; @@ -629,7 +630,7 @@ sai_object_id_t translate_vid_to_rid( local_vid_to_rid[vid] = rid; - SWSS_LOG_DEBUG("translated VID 0x%lx to RID 0x%lx", vid, rid); + SWSS_LOG_DEBUG("translated VID 0x%" PRIx64 " to RID 0x%" PRIx64, vid, rid); return rid; } @@ -1258,7 +1259,7 @@ sai_status_t handle_generic( if (switch_id == SAI_NULL_OBJECT_ID) { - SWSS_LOG_THROW("invalid switch_id translated from VID 0x%lx", object_id); + SWSS_LOG_THROW("invalid switch_id translated from VID 0x%" PRIx64, object_id); } if (object_type != SAI_OBJECT_TYPE_SWITCH) @@ -1319,7 +1320,7 @@ sai_status_t handle_generic( { on_switch_create(switch_id); gSwitchId = real_object_id; - SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%lx", gSwitchId); + SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%" PRIx64, gSwitchId); } } @@ -2130,7 +2131,7 @@ void on_switch_create_in_init_view( #ifdef SAITHRIFT gSwitchId = switch_rid; - SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%lx", gSwitchId); + SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%" PRIx64, gSwitchId); #endif /* @@ -4142,7 +4143,7 @@ int syncd_main(int argc, char **argv) } } - SWSS_LOG_NOTICE("Removing the switch gSwitchId=0x%lx", gSwitchId); + SWSS_LOG_NOTICE("Removing the switch gSwitchId=0x%" PRIx64, gSwitchId); #ifdef SAI_SUPPORT_UNINIT_DATA_PLANE_ON_REMOVAL @@ -4182,7 +4183,7 @@ int syncd_main(int argc, char **argv) if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_NOTICE("Can't delete a switch. gSwitchId=0x%lx status=%s", gSwitchId, + SWSS_LOG_NOTICE("Can't delete a switch. gSwitchId=0x%" PRIx64 " status=%s", gSwitchId, sai_serialize_status(status).c_str()); } diff --git a/syncd/syncd_applyview.cpp b/syncd/syncd_applyview.cpp index a59fe370bc1c..91085737627b 100644 --- a/syncd/syncd_applyview.cpp +++ b/syncd/syncd_applyview.cpp @@ -4,6 +4,7 @@ #include "swss/logger.h" #include "swss/dbconnector.h" +#include #include #include @@ -1434,7 +1435,7 @@ class AsicView v.insert(v.begin() + index, op); - SWSS_LOG_INFO("move 0x%lx all way up (not in map): %s to index: %zu", op.vid, + SWSS_LOG_INFO("move 0x%" PRIx64 " all way up (not in map): %s to index: %zu", op.vid, sai_serialize_object_type(redis_sai_object_type_query(op.vid)).c_str(),index); index++; @@ -1503,7 +1504,7 @@ class AsicView v.insert(v.begin() + index, op); - SWSS_LOG_INFO("move 0x%lx in the middle up: %s (last: %zu curr: %zu)", op.vid, + SWSS_LOG_INFO("move 0x%" PRIx64 " in the middle up: %s (last: %zu curr: %zu)", op.vid, sai_serialize_object_type(redis_sai_object_type_query(op.vid)).c_str(), lastOpIdDecRefIndex, index); index++; @@ -5736,7 +5737,7 @@ std::shared_ptr getSaiAttrFromDefaultValue( if (tg == currentView.ridToVid.end()) { - SWSS_LOG_THROW("default trap group RID 0x%lx doesn't exist in current view", currentView.defaultTrapGroupRid); + SWSS_LOG_THROW("default trap group RID 0x%" PRIx64 " doesn't exist in current view", currentView.defaultTrapGroupRid); } sai_attribute_t at; @@ -7290,14 +7291,14 @@ void checkMap( sai_object_id_t v = it.second; if (firstV2R.find(v) == firstV2R.end()) - SWSS_LOG_ERROR("%s (0x%lx:0x%lx) is missing from %s", firstR2Vname, r, v, firstV2Rname); + SWSS_LOG_ERROR("%s (0x%" PRIx64 ":0x%" PRIx64 ") is missing from %s", firstR2Vname, r, v, firstV2Rname); else if (firstV2R.at(v) != r) - SWSS_LOG_ERROR("mismatch on %s (0x%lx:0x%lx) vs %s (0x%lx:0x%lx)", firstR2Vname, r, v, firstV2Rname, v, firstV2R.at(v)); + SWSS_LOG_ERROR("mismatch on %s (0x%" PRIx64 ":0x%" PRIx64 ") vs %s (0x%" PRIx64 ":0x%" PRIx64 ")", firstR2Vname, r, v, firstV2Rname, v, firstV2R.at(v)); if (secondR2V.find(r) == secondR2V.end()) - SWSS_LOG_ERROR("%s (0x%lx:0x%lx) is missing from %s", firstR2Vname, r, v, secondR2Vname); + SWSS_LOG_ERROR("%s (0x%" PRIx64 ":0x%" PRIx64 ") is missing from %s", firstR2Vname, r, v, secondR2Vname); else if (secondV2R.find(secondR2V.at(r)) == secondV2R.end()) - SWSS_LOG_ERROR("%s (0x%lx:0x%lx) is missing from %s", firstR2Vname, r, secondR2V.at(r), secondV2Rname); + SWSS_LOG_ERROR("%s (0x%" PRIx64 ":0x%" PRIx64 ") is missing from %s", firstR2Vname, r, secondR2V.at(r), secondV2Rname); } } @@ -7360,7 +7361,7 @@ void createPreMatchMapForObject( if (cur.oOids.at(cVid)->getObjectType() != tmp.oOids.at(tVid)->getObjectType()) continue; - SWSS_LOG_INFO("inserting pre match entry for %s:%s: 0x%lx (tmp) -> 0x%lx (cur)", + SWSS_LOG_INFO("inserting pre match entry for %s:%s: 0x%" PRIx64 " (tmp) -> 0x%" PRIx64 " (cur)", tObj->str_object_id.c_str(), cAttr->getAttrMetadata()->attridname, tVid, @@ -7742,7 +7743,7 @@ sai_object_id_t asic_translate_vid_to_rid( sai_object_id_t rid = currentIt->second; - SWSS_LOG_INFO("translated VID 0x%lx to RID 0x%lx", vid, rid); + SWSS_LOG_INFO("translated VID 0x%" PRIx64 " to RID 0x%" PRIx64, vid, rid); return rid; } diff --git a/syncd/syncd_flex_counter.cpp b/syncd/syncd_flex_counter.cpp index 3a59a0fb7867..0370487067aa 100644 --- a/syncd/syncd_flex_counter.cpp +++ b/syncd/syncd_flex_counter.cpp @@ -1,6 +1,7 @@ #include "syncd_flex_counter.h" #include "syncd.h" #include "swss/redisapi.h" +#include /* Global map with FlexCounter instances for different polling interval */ static std::map> g_flex_counters_map; @@ -571,7 +572,7 @@ void FlexCounter::removePort( auto it = fc.m_portCounterIdsMap.find(portVid); if (it == fc.m_portCounterIdsMap.end()) { - SWSS_LOG_NOTICE("Trying to remove nonexisting port counter Ids 0x%lx", portVid); + SWSS_LOG_NOTICE("Trying to remove nonexisting port counter Ids 0x%" PRIx64, portVid); // Remove flex counter if all counter IDs and plugins are unregistered if (fc.isEmpty()) @@ -631,7 +632,7 @@ void FlexCounter::removeQueue( if (!found) { - SWSS_LOG_NOTICE("Trying to remove nonexisting queue from flex counter 0x%lx", queueVid); + SWSS_LOG_NOTICE("Trying to remove nonexisting queue from flex counter 0x%" PRIx64, queueVid); return; } @@ -678,7 +679,7 @@ void FlexCounter::removePriorityGroup( if (!found) { - SWSS_LOG_NOTICE("Trying to remove nonexisting PG from flex counter 0x%lx", priorityGroupVid); + SWSS_LOG_NOTICE("Trying to remove nonexisting PG from flex counter 0x%" PRIx64, priorityGroupVid); return; } @@ -703,7 +704,7 @@ void FlexCounter::removeRif( auto it = fc.m_rifCounterIdsMap.find(rifVid); if (it == fc.m_rifCounterIdsMap.end()) { - SWSS_LOG_NOTICE("Trying to remove nonexisting router interface counter from Id 0x%lx", rifVid); + SWSS_LOG_NOTICE("Trying to remove nonexisting router interface counter from Id 0x%" PRIx64, rifVid); // Remove flex counter if all counter IDs and plugins are unregistered if (fc.isEmpty()) @@ -752,7 +753,7 @@ void FlexCounter::removeBufferPool( if (!found) { - SWSS_LOG_NOTICE("Trying to remove nonexisting buffer pool 0x%lx from flex counter %s", bufferPoolVid, fc.m_instanceId.c_str()); + SWSS_LOG_NOTICE("Trying to remove nonexisting buffer pool 0x%" PRIx64 " from flex counter %s", bufferPoolVid, fc.m_instanceId.c_str()); return; } @@ -1030,7 +1031,7 @@ void FlexCounter::collectPortCounters(_In_ swss::Table &countersTable) portStats.data()); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get stats of port 0x%lx: %d", portId, status); + SWSS_LOG_ERROR("Failed to get stats of port 0x%" PRIx64 ": %d", portId, status); continue; } @@ -1080,7 +1081,7 @@ void FlexCounter::collectQueueCounters(_In_ swss::Table &countersTable) queueStats.data()); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("%s: failed to get stats of queue 0x%lx: %d", m_instanceId.c_str(), queueVid, status); + SWSS_LOG_ERROR("%s: failed to get stats of queue 0x%" PRIx64 ": %d", m_instanceId.c_str(), queueVid, status); continue; } if (m_statsMode == SAI_STATS_MODE_READ_AND_CLEAR){ @@ -1090,7 +1091,7 @@ void FlexCounter::collectQueueCounters(_In_ swss::Table &countersTable) (const sai_stat_id_t *)queueCounterIds.data()); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("%s: failed to clear stats of queue 0x%lx: %d", m_instanceId.c_str(), queueVid, status); + SWSS_LOG_ERROR("%s: failed to clear stats of queue 0x%" PRIx64 ": %d", m_instanceId.c_str(), queueVid, status); continue; } } @@ -1137,7 +1138,7 @@ void FlexCounter::collectQueueAttrs(_In_ swss::Table &countersTable) if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get attr of queue 0x%lx: %d", queueVid, status); + SWSS_LOG_ERROR("Failed to get attr of queue 0x%" PRIx64 ": %d", queueVid, status); continue; } @@ -1181,7 +1182,7 @@ void FlexCounter::collectPriorityGroupCounters(_In_ swss::Table &countersTable) priorityGroupStats.data()); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("%s: failed to get %ld/%ld stats of PG 0x%lx: %d", m_instanceId.c_str(), priorityGroupCounterIds.size(), priorityGroupStats.size(), priorityGroupVid, status); + SWSS_LOG_ERROR("%s: failed to get %ld/%ld stats of PG 0x%" PRIx64 ": %d", m_instanceId.c_str(), priorityGroupCounterIds.size(), priorityGroupStats.size(), priorityGroupVid, status); continue; } if (m_statsMode == SAI_STATS_MODE_READ_AND_CLEAR){ @@ -1191,7 +1192,7 @@ void FlexCounter::collectPriorityGroupCounters(_In_ swss::Table &countersTable) (const sai_stat_id_t *)priorityGroupCounterIds.data()); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("%s: failed to clear %ld/%ld stats of PG 0x%lx: %d", m_instanceId.c_str(), priorityGroupCounterIds.size(), priorityGroupStats.size(), priorityGroupVid, status); + SWSS_LOG_ERROR("%s: failed to clear %ld/%ld stats of PG 0x%" PRIx64 ": %d", m_instanceId.c_str(), priorityGroupCounterIds.size(), priorityGroupStats.size(), priorityGroupVid, status); continue; } } @@ -1238,7 +1239,7 @@ void FlexCounter::collectPriorityGroupAttrs(_In_ swss::Table &countersTable) if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get attr of PG 0x%lx: %d", priorityGroupVid, status); + SWSS_LOG_ERROR("Failed to get attr of PG 0x%" PRIx64 ": %d", priorityGroupVid, status); continue; } @@ -1280,7 +1281,7 @@ void FlexCounter::collectRifCounters(_In_ swss::Table &countersTable) rifStats.data()); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to get stats of router interface 0x%lx: %d", rifId, status); + SWSS_LOG_ERROR("Failed to get stats of router interface 0x%" PRIx64 ": %d", rifId, status); continue; } diff --git a/syncd/syncd_notifications.cpp b/syncd/syncd_notifications.cpp index 86de9abc4cd3..ff5fda1c049c 100644 --- a/syncd/syncd_notifications.cpp +++ b/syncd/syncd_notifications.cpp @@ -1,6 +1,7 @@ #include "syncd.h" #include "sairedis.h" +#include #include #include #include @@ -175,7 +176,7 @@ void redisPutFdbEntryToAsicView( ] }] */ - SWSS_LOG_ERROR("received a flush port fdb event, port_oid = 0x%lx, bv_id = 0x%lx, unsupported", port_oid, bv_id); + SWSS_LOG_ERROR("received a flush port fdb event, port_oid = 0x%" PRIx64 ", bv_id = 0x%" PRIx64 ", unsupported", port_oid, bv_id); } else if (!port_oid && bv_id) { @@ -196,12 +197,12 @@ void redisPutFdbEntryToAsicView( ] }] */ - SWSS_LOG_ERROR("received a flush vlan fdb event, port_oid = 0x%lx, bv_id = 0x%lx, unsupported", port_oid, bv_id); + SWSS_LOG_ERROR("received a flush vlan fdb event, port_oid = 0x%" PRIx64 ", bv_id = 0x%" PRIx64 ", unsupported", port_oid, bv_id); } else { - SWSS_LOG_ERROR("received a flush fdb event, port_oid = 0x%lx, bv_id = 0x%lx, unsupported", port_oid, bv_id); + SWSS_LOG_ERROR("received a flush fdb event, port_oid = 0x%" PRIx64 ", bv_id = 0x%" PRIx64 ", unsupported", port_oid, bv_id); } return; @@ -282,7 +283,7 @@ bool check_fdb_event_notification_data( if (!check_rid_exists(data.fdb_entry.bv_id)) { - SWSS_LOG_ERROR("bv_id RID 0x%lx is not present on local ASIC DB: %s", data.fdb_entry.bv_id, + SWSS_LOG_ERROR("bv_id RID 0x%" PRIx64 " is not present on local ASIC DB: %s", data.fdb_entry.bv_id, sai_serialize_fdb_entry(data.fdb_entry).c_str()); result = false; @@ -290,7 +291,7 @@ bool check_fdb_event_notification_data( if (!check_rid_exists(data.fdb_entry.switch_id) || data.fdb_entry.switch_id == SAI_NULL_OBJECT_ID) { - SWSS_LOG_ERROR("switch_id RID 0x%lx is not present on local ASIC DB: %s", data.fdb_entry.bv_id, + SWSS_LOG_ERROR("switch_id RID 0x%" PRIx64 " is not present on local ASIC DB: %s", data.fdb_entry.bv_id, sai_serialize_fdb_entry(data.fdb_entry).c_str()); result = false; @@ -314,7 +315,7 @@ bool check_fdb_event_notification_data( if (!check_rid_exists(attr.value.oid)) { - SWSS_LOG_WARN("RID 0x%lx on %s is not present on local ASIC DB", attr.value.oid, meta->attridname); + SWSS_LOG_WARN("RID 0x%" PRIx64 " on %s is not present on local ASIC DB", attr.value.oid, meta->attridname); result = false; } @@ -876,6 +877,6 @@ void check_notifications_pointers( * Here we translated pointer, just log it. */ - SWSS_LOG_INFO("%s: 0x%lX (orch) => 0x%lX (syncd)", meta->attridname, (uint64_t)prev, (uint64_t)attr.value.ptr); + SWSS_LOG_INFO("%s: 0x%" PRIx64 " (orch) => 0x%" PRIx64 " (syncd)", meta->attridname, (uint64_t)prev, (uint64_t)attr.value.ptr); } } diff --git a/vslib/src/sai_vs_generic_remove.cpp b/vslib/src/sai_vs_generic_remove.cpp index b42b9cdc6025..7c208954f954 100644 --- a/vslib/src/sai_vs_generic_remove.cpp +++ b/vslib/src/sai_vs_generic_remove.cpp @@ -3,6 +3,7 @@ #include "sai_vs_switch_BCM56850.h" #include "sai_vs_switch_MLNX2700.h" +#include #include sai_status_t internal_vs_generic_remove( @@ -39,7 +40,7 @@ void vs_dump_switch_database_for_warm_restart( if (it == g_switch_state_map.end()) { - SWSS_LOG_THROW("switch don't exists 0x%lx", switch_id); + SWSS_LOG_THROW("switch don't exists 0x%" PRIx64, switch_id); } if (g_warm_boot_write_file == NULL) diff --git a/vslib/src/sai_vs_hostintf.cpp b/vslib/src/sai_vs_hostintf.cpp index b43dd19ea1e5..98345e1cc608 100644 --- a/vslib/src/sai_vs_hostintf.cpp +++ b/vslib/src/sai_vs_hostintf.cpp @@ -899,10 +899,9 @@ void veth2tap_fun(std::shared_ptr info) uint16_t tci = htons(aux->tp_vlan_tci); uint16_t tpid = htons(IEEE_8021Q_ETHER_TYPE); - uint16_t* pvlan = (uint16_t*)(buffer + 2 * MAC_ADDRESS_SIZE); - - pvlan[0] = tpid; - pvlan[1] = tci; + uint8_t* pvlan = (uint8_t *)(buffer + 2 * MAC_ADDRESS_SIZE); + memcpy(pvlan, &tpid, sizeof(uint16_t)); + memcpy(pvlan + sizeof(uint16_t), &tci, sizeof(uint16_t)); size += VLAN_TAG_SIZE; diff --git a/vslib/src/sai_vs_interfacequery.cpp b/vslib/src/sai_vs_interfacequery.cpp index 41f47220c0c3..60605055e7b7 100644 --- a/vslib/src/sai_vs_interfacequery.cpp +++ b/vslib/src/sai_vs_interfacequery.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -257,7 +258,7 @@ void channelOpSetStats( uint64_t value; - if (sscanf(fvValue(v).c_str(), "%lu", &value) != 1) + if (sscanf(fvValue(v).c_str(), "%" PRIu64, &value) != 1) { SWSS_LOG_ERROR("failed to deserialize %s as couner value uint64_t", fvValue(v).c_str()); }