From 65cbd55f6e382aa3554642ae19c2deaba1c3e20d Mon Sep 17 00:00:00 2001 From: "arheneus@marvell.com" <51254330+antony-rheneus@users.noreply.github.com> Date: Fri, 16 Aug 2019 10:59:35 +0530 Subject: [PATCH] [build]: Fix compiling warnings using ARM 32 bit compiler (#1015) --- fpmsyncd/fpm/fpm.h | 2 +- fpmsyncd/fpmlink.cpp | 2 +- fpmsyncd/fpmsyncd.cpp | 9 +++++---- orchagent/countercheckorch.cpp | 8 ++++---- orchagent/crmorch.cpp | 2 +- orchagent/pfcactionhandler.cpp | 6 +++--- orchagent/portsorch.cpp | 9 +++++---- orchagent/qosorch.cpp | 2 +- orchagent/watermarkorch.cpp | 4 ++-- warmrestart/warmRestartAssist.h | 2 +- 10 files changed, 24 insertions(+), 22 deletions(-) diff --git a/fpmsyncd/fpm/fpm.h b/fpmsyncd/fpm/fpm.h index 96f05f486573..8af9b30ae9ee 100644 --- a/fpmsyncd/fpm/fpm.h +++ b/fpmsyncd/fpm/fpm.h @@ -221,7 +221,7 @@ fpm_msg_next (fpm_msg_hdr_t *hdr, size_t *len) *len -= msg_len; } - return (fpm_msg_hdr_t *) (((char*) hdr) + msg_len); + return reinterpret_cast(static_cast(((char*) hdr) + msg_len)); } /* diff --git a/fpmsyncd/fpmlink.cpp b/fpmsyncd/fpmlink.cpp index 2147f85d7dfe..bed95b1dd46c 100644 --- a/fpmsyncd/fpmlink.cpp +++ b/fpmsyncd/fpmlink.cpp @@ -106,7 +106,7 @@ void FpmLink::readData() /* Check for complete messages */ while (true) { - hdr = (fpm_msg_hdr_t *)(m_messageBuffer + start); + hdr = reinterpret_cast(static_cast(m_messageBuffer + start)); left = m_pos - start; if (left < FPM_MSG_HDR_LEN) break; diff --git a/fpmsyncd/fpmsyncd.cpp b/fpmsyncd/fpmsyncd.cpp index 6f5dd88d8c0f..8040a7ecb47e 100644 --- a/fpmsyncd/fpmsyncd.cpp +++ b/fpmsyncd/fpmsyncd.cpp @@ -1,4 +1,5 @@ #include +#include #include "logger.h" #include "select.h" #include "selectabletimer.h" @@ -84,7 +85,7 @@ int main(int argc, char **argv) if (warmStartEnabled) { /* Obtain warm-restart timer defined for routing application */ - uint32_t warmRestartIval = sync.m_warmStartHelper.getRestartTimer(); + time_t warmRestartIval = sync.m_warmStartHelper.getRestartTimer(); if (!warmRestartIval) { warmStartTimer.setInterval(timespec{DEFAULT_ROUTING_RESTART_INTERVAL, 0}); @@ -149,7 +150,7 @@ int main(int argc, char **argv) if (eoiuFlagsSet(bgpStateTable)) { /* Obtain eoiu hold timer defined for bgp docker */ - uint32_t eoiuHoldIval = WarmStart::getWarmStartTimer("eoiu_hold", "bgp"); + uintmax_t eoiuHoldIval = WarmStart::getWarmStartTimer("eoiu_hold", "bgp"); if (!eoiuHoldIval) { eoiuHoldTimer.setInterval(timespec{DEFAULT_EOIU_HOLD_INTERVAL, 0}); @@ -157,11 +158,11 @@ int main(int argc, char **argv) } else { - eoiuHoldTimer.setInterval(timespec{eoiuHoldIval, 0}); + eoiuHoldTimer.setInterval(timespec{(time_t)eoiuHoldIval, 0}); } eoiuHoldTimer.start(); s.addSelectable(&eoiuHoldTimer); - SWSS_LOG_NOTICE("Warm-Restart started EOIU hold timer which is to expire in %d seconds.", eoiuHoldIval); + SWSS_LOG_NOTICE("Warm-Restart started EOIU hold timer which is to expire in %" PRIuMAX " seconds.", eoiuHoldIval); s.removeSelectable(&eoiuCheckTimer); continue; } diff --git a/orchagent/countercheckorch.cpp b/orchagent/countercheckorch.cpp index 671eef1d6147..68edb69e2042 100644 --- a/orchagent/countercheckorch.cpp +++ b/orchagent/countercheckorch.cpp @@ -79,13 +79,13 @@ void CounterCheckOrch::mcCounterCheck() bool isLossy = ((1 << prio) & pfcMask) == 0; if (newMcCounters[prio] == numeric_limits::max()) { - SWSS_LOG_WARN("Could not retreive MC counters on queue %" PRIu64 " port %s", + SWSS_LOG_WARN("Could not retreive MC counters on queue %zu port %s", prio, port.m_alias.c_str()); } else if (!isLossy && mcCounters[prio] < newMcCounters[prio]) { - SWSS_LOG_WARN("Got Multicast %" PRIu64 " frame(s) on lossless queue %" PRIu64 " port %s", + SWSS_LOG_WARN("Got Multicast %" PRIu64 " frame(s) on lossless queue %zu port %s", newMcCounters[prio] - mcCounters[prio], prio, port.m_alias.c_str()); @@ -125,13 +125,13 @@ void CounterCheckOrch::pfcFrameCounterCheck() bool isLossy = ((1 << prio) & pfcMask) == 0; if (newCounters[prio] == numeric_limits::max()) { - SWSS_LOG_WARN("Could not retreive PFC frame count on queue %" PRIu64 " port %s", + SWSS_LOG_WARN("Could not retreive PFC frame count on queue %zu port %s", prio, port.m_alias.c_str()); } else if (isLossy && counters[prio] < newCounters[prio]) { - SWSS_LOG_WARN("Got PFC %" PRIu64 " frame(s) on lossy queue %" PRIu64 " port %s", + SWSS_LOG_WARN("Got PFC %" PRIu64 " frame(s) on lossy queue %zu port %s", newCounters[prio] - counters[prio], prio, port.m_alias.c_str()); diff --git a/orchagent/crmorch.cpp b/orchagent/crmorch.cpp index e5fc39f79634..9e26cd58aa15 100644 --- a/orchagent/crmorch.cpp +++ b/orchagent/crmorch.cpp @@ -240,7 +240,7 @@ void CrmOrch::handleSetCommand(const string& key, const vector& if (field == CRM_POLLING_INTERVAL) { m_pollingInterval = chrono::seconds(to_uint(value)); - auto interv = timespec { .tv_sec = m_pollingInterval.count(), .tv_nsec = 0 }; + auto interv = timespec { .tv_sec = (time_t)m_pollingInterval.count(), .tv_nsec = 0 }; m_timer->setInterval(interv); m_timer->reset(); } diff --git a/orchagent/pfcactionhandler.cpp b/orchagent/pfcactionhandler.cpp index c726d18b58ad..df0977cb66f6 100644 --- a/orchagent/pfcactionhandler.cpp +++ b/orchagent/pfcactionhandler.cpp @@ -404,7 +404,7 @@ bool PfcWdLossyHandler::getHwCounters(PfcWdHwStats& counters) return false; } - sai_object_id_t pg = portInstance.m_priority_group_ids[getQueueId()]; + sai_object_id_t pg = portInstance.m_priority_group_ids[static_cast (getQueueId())]; vector pgStats; pgStats.resize(pgStatIds.size()); @@ -469,7 +469,7 @@ PfcWdZeroBufferHandler::PfcWdZeroBufferHandler(sai_object_id_t port, return; } - sai_object_id_t pg = portInstance.m_priority_group_ids[queueId]; + sai_object_id_t pg = portInstance.m_priority_group_ids[static_cast (queueId)]; attr.id = SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE; @@ -521,7 +521,7 @@ PfcWdZeroBufferHandler::~PfcWdZeroBufferHandler(void) return; } - sai_object_id_t pg = portInstance.m_priority_group_ids[getQueueId()]; + sai_object_id_t pg = portInstance.m_priority_group_ids[size_t(getQueueId())]; attr.id = SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE; attr.value.oid = m_originalPgBufferProfile; diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index a0387426bc80..45c174158e58 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1430,7 +1430,8 @@ bool PortsOrch::bake() vector tuples; string value; bool foundPortConfigDone = m_portTable->hget("PortConfigDone", "count", value); - unsigned long portCount; + uintmax_t portCount; + char* endPtr = NULL; SWSS_LOG_NOTICE("foundPortConfigDone = %d", foundPortConfigDone); bool foundPortInitDone = m_portTable->get("PortInitDone", tuples); @@ -1447,12 +1448,12 @@ bool PortsOrch::bake() return false; } - portCount = stoul(value); - SWSS_LOG_NOTICE("portCount = %" PRIu64 ", m_portCount = %u", portCount, m_portCount); + portCount = strtoumax(value.c_str(), &endPtr, 0); + SWSS_LOG_NOTICE("portCount = %" PRIuMAX ", m_portCount = %u", portCount, m_portCount); if (portCount != keys.size() - 2) { // Invalid port table - SWSS_LOG_ERROR("Invalid port table: portCount, expecting %" PRIu64 ", got %" PRIu64, + SWSS_LOG_ERROR("Invalid port table: portCount, expecting %" PRIuMAX ", got %zu", portCount, keys.size() - 2); cleanPortTable(keys); diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 0486ad3af688..12783468fb60 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -1053,7 +1053,7 @@ bool QosOrch::applySchedulerToQueueSchedulerGroup(Port &port, size_t queue_ind, const sai_object_id_t group_id = getSchedulerGroup(port, queue_id); if(group_id == SAI_NULL_OBJECT_ID) { - SWSS_LOG_ERROR("Failed to find a scheduler group for port: %s queue: %" PRIu64, port.m_alias.c_str(), queue_ind); + SWSS_LOG_ERROR("Failed to find a scheduler group for port: %s queue: %zu", port.m_alias.c_str(), queue_ind); return false; } diff --git a/orchagent/watermarkorch.cpp b/orchagent/watermarkorch.cpp index 11737badf68c..0b8c20e91197 100644 --- a/orchagent/watermarkorch.cpp +++ b/orchagent/watermarkorch.cpp @@ -98,7 +98,7 @@ void WatermarkOrch::handleWmConfigUpdate(const std::string &key, const std::vect { if (i.first == "interval") { - auto intervT = timespec { .tv_sec = to_uint(i.second.c_str()) , .tv_nsec = 0 }; + auto intervT = timespec { .tv_sec = static_cast(to_uint(i.second.c_str())), .tv_nsec = 0 }; m_telemetryTimer->setInterval(intervT); // reset the timer interval when current timer expires m_timerChanged = true; @@ -295,7 +295,7 @@ void WatermarkOrch::clearSingleWm(Table *table, string wm_name, vector vfvt = {{wm_name, "0"}}; diff --git a/warmrestart/warmRestartAssist.h b/warmrestart/warmRestartAssist.h index 2d5e387ee130..227815c264e1 100644 --- a/warmrestart/warmRestartAssist.h +++ b/warmrestart/warmRestartAssist.h @@ -108,7 +108,7 @@ class AppRestartAssist std::string m_appTableName; // application table name bool m_warmStartInProgress; // indicate if warm start is in progress - uint32_t m_reconcileTimer; // reconcile timer value + time_t m_reconcileTimer; // reconcile timer value SelectableTimer m_warmStartTimer; // reconcile timer // Set or get cache entry state