wifi: Use casts to eliminate Visual Studio compiler warnings

This commit is contained in:
Robert Ammon
2018-05-12 22:09:39 +02:00
parent 2bd1f1fb05
commit b40d64f702
18 changed files with 52 additions and 52 deletions

View File

@@ -583,7 +583,7 @@ ApWifiMac::GetHtOperation (void) const
}
}
}
operation.SetRxHighestSupportedDataRate (maxSupportedRate / 1e6); //in Mbit/s
operation.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupportedRate / 1e6)); //in Mbit/s
operation.SetTxMcsSetDefined (nMcs > 0);
operation.SetTxMaxNSpatialStreams (maxSpatialStream);
//To be filled in once supported

View File

@@ -173,7 +173,7 @@ void
DcfManager::SetSlot (Time slotTime)
{
NS_LOG_FUNCTION (this << slotTime);
m_slotTimeUs = slotTime.GetMicroSeconds ();
m_slotTimeUs = static_cast<uint32_t> (slotTime.GetMicroSeconds ());
}
void
@@ -448,7 +448,7 @@ DcfManager::UpdateBackoff (void)
Time backoffStart = GetBackoffStartFor (state);
if (backoffStart <= Simulator::Now ())
{
uint32_t nus = (Simulator::Now () - backoffStart).GetMicroSeconds ();
uint32_t nus = static_cast<uint32_t> ((Simulator::Now () - backoffStart).GetMicroSeconds ());
uint32_t nIntSlots = nus / m_slotTimeUs;
/*
* EDCA behaves slightly different to DCA. For EDCA we

View File

@@ -73,14 +73,14 @@ EdcaParameterSet::SetBeAci (uint8_t aci)
void
EdcaParameterSet::SetBeCWmin (uint32_t cwMin)
{
uint8_t ECWmin = log2 (cwMin + 1);
uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
m_acBE |= (ECWmin & 0x0f) << 8;
}
void
EdcaParameterSet::SetBeCWmax (uint32_t cwMax)
{
uint8_t ECWmax = log2 (cwMax + 1);
uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
m_acBE |= (ECWmax & 0x0f) << 12;
}
@@ -105,14 +105,14 @@ EdcaParameterSet::SetBkAci (uint8_t aci)
void
EdcaParameterSet::SetBkCWmin (uint32_t cwMin)
{
uint8_t ECWmin = log2 (cwMin + 1);
uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
m_acBK |= (ECWmin & 0x0f) << 8;
}
void
EdcaParameterSet::SetBkCWmax (uint32_t cwMax)
{
uint8_t ECWmax = log2 (cwMax + 1);
uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
m_acBK |= (ECWmax & 0x0f) << 12;
}
@@ -137,14 +137,14 @@ EdcaParameterSet::SetViAci (uint8_t aci)
void
EdcaParameterSet::SetViCWmin (uint32_t cwMin)
{
uint8_t ECWmin = log2 (cwMin + 1);
uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
m_acVI |= (ECWmin & 0x0f) << 8;
}
void
EdcaParameterSet::SetViCWmax (uint32_t cwMax)
{
uint8_t ECWmax = log2 (cwMax + 1);
uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
m_acVI |= (ECWmax & 0x0f) << 12;
}
@@ -169,14 +169,14 @@ EdcaParameterSet::SetVoAci (uint8_t aci)
void
EdcaParameterSet::SetVoCWmin (uint32_t cwMin)
{
uint8_t ECWmin = log2 (cwMin + 1);
uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
m_acVO |= (ECWmin & 0x0f) << 8;
}
void
EdcaParameterSet::SetVoCWmax (uint32_t cwMax)
{
uint8_t ECWmax = log2 (cwMax + 1);
uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
m_acVO |= (ECWmax & 0x0f) << 12;
}

View File

@@ -151,7 +151,7 @@ IdealWifiManager::DoInitialize ()
}
else
{
guardInterval = GetPhy ()->GetGuardInterval ().GetNanoSeconds ();
guardInterval = static_cast<uint16_t> (GetPhy ()->GetGuardInterval ().GetNanoSeconds ());
}
txVector.SetGuardInterval (guardInterval);
for (uint8_t k = 1; k <= GetPhy ()->GetMaxSupportedTxSpatialStreams (); k++)
@@ -321,7 +321,7 @@ IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st)
txVector.SetMode (mode);
if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
{
guardInterval = std::max (GetShortGuardInterval (station) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800);
guardInterval = static_cast<uint16_t> (std::max (GetShortGuardInterval (station) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800));
txVector.SetGuardInterval (guardInterval);
// If the node and peer are both VHT capable, only search VHT modes
if (HasVhtSupported () && GetVhtSupported (station))
@@ -365,7 +365,7 @@ IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st)
}
else if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
{
guardInterval = std::max (GetShortGuardInterval (station) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800);
guardInterval = static_cast<uint16_t> (std::max (GetShortGuardInterval (station) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800));
txVector.SetGuardInterval (guardInterval);
// If the node and peer are both HE capable, only search HE modes
if (HasHeSupported () && GetHeSupported (station))
@@ -488,7 +488,7 @@ IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st)
}
else
{
guardInterval = std::max (GetShortGuardInterval (station) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800);
guardInterval = static_cast<uint16_t> (std::max (GetShortGuardInterval (station) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800));
}
if (m_currentRate != maxMode.GetDataRate (channelWidth, guardInterval, selectedNss))
{

View File

@@ -441,7 +441,7 @@ MgtProbeResponseHeader::Serialize (Buffer::Iterator start) const
//ibss parameter set
Buffer::Iterator i = start;
i.WriteHtolsbU64 (Simulator::Now ().GetMicroSeconds ());
i.WriteHtolsbU16 (m_beaconInterval / 1024);
i.WriteHtolsbU16 (static_cast<uint16_t> (m_beaconInterval / 1024));
i = m_capability.Serialize (i);
i = m_ssid.Serialize (i);
i = m_rates.Serialize (i);

View File

@@ -77,7 +77,7 @@ MpduAggregator::Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacke
Ptr<Packet> pad = Create<Packet> (padding);
aggregatedPacket->AddAtEnd (pad);
}
currentHdr.SetLength (packet->GetSize ());
currentHdr.SetLength (static_cast<uint16_t> (packet->GetSize ()));
currentPacket = packet->Copy ();
currentPacket->AddHeader (currentHdr);
@@ -102,7 +102,7 @@ MpduAggregator::AggregateSingleMpdu (Ptr<const Packet> packet, Ptr<Packet> aggre
}
currentHdr.SetEof (1);
currentHdr.SetLength (packet->GetSize ());
currentHdr.SetLength (static_cast<uint16_t> (packet->GetSize ()));
currentPacket = packet->Copy ();
currentPacket->AddHeader (currentHdr);
@@ -117,7 +117,7 @@ MpduAggregator::AddHeaderAndPad (Ptr<Packet> packet, bool last, bool isSingleMpd
//This is called to prepare packets from the aggregate queue to be sent so no need to check total size since it has already been
//done before when deciding how many packets to add to the queue
currentHdr.SetLength (packet->GetSize ());
currentHdr.SetLength (static_cast<uint16_t> (packet->GetSize ()));
if (isSingleMpdu)
{
currentHdr.SetEof (1);

View File

@@ -80,7 +80,7 @@ MsduAggregator::Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacke
}
currentHdr.SetDestinationAddr (dest);
currentHdr.SetSourceAddr (src);
currentHdr.SetLength (packet->GetSize ());
currentHdr.SetLength (static_cast<uint16_t> (packet->GetSize ()));
currentPacket = packet->Copy ();
currentPacket->AddHeader (currentHdr);

View File

@@ -204,7 +204,7 @@ RegularWifiMac::GetHtCapabilities (void) const
NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate);
}
}
capabilities.SetRxHighestSupportedDataRate (maxSupportedRate / 1e6); //in Mbit/s
capabilities.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupportedRate / 1e6)); //in Mbit/s
capabilities.SetTxMcsSetDefined (m_phy->GetNMcs () > 0);
capabilities.SetTxMaxNSpatialStreams (m_phy->GetMaxSupportedTxSpatialStreams ());
//we do not support unequal modulations
@@ -271,8 +271,8 @@ RegularWifiMac::GetVhtCapabilities (void) const
NS_LOG_DEBUG ("Updating maxSupportedRateLGI to " << maxSupportedRateLGI);
}
}
capabilities.SetRxHighestSupportedLgiDataRate (maxSupportedRateLGI / 1e6); //in Mbit/s
capabilities.SetTxHighestSupportedLgiDataRate (maxSupportedRateLGI / 1e6); //in Mbit/s
capabilities.SetRxHighestSupportedLgiDataRate (static_cast<uint16_t> (maxSupportedRateLGI / 1e6)); //in Mbit/s
capabilities.SetTxHighestSupportedLgiDataRate (static_cast<uint16_t> (maxSupportedRateLGI / 1e6)); //in Mbit/s
//To be filled in once supported
capabilities.SetRxStbc (0);
capabilities.SetTxStbc (0);

View File

@@ -249,7 +249,7 @@ RraaWifiManager::InitThresholds (RraaWifiRemoteStation *station)
mtl = 1;
}
WifiRraaThresholds th;
th.m_ewnd = ceil (m_tau / totalTxTime.GetSeconds ());
th.m_ewnd = static_cast<uint32_t> (ceil (m_tau / totalTxTime.GetSeconds ()));
th.m_ori = ori;
th.m_mtl = mtl;
station->m_thresholds.push_back (std::make_pair (th, mode));

View File

@@ -296,7 +296,7 @@ RrpaaWifiManager::InitThresholds (RrpaaWifiRemoteStation *station)
mtl = nextMtl;
}
WifiRrpaaThresholds th;
th.m_ewnd = ceil (m_tau / totalTxTime.GetSeconds ());
th.m_ewnd = static_cast<uint32_t> (ceil (m_tau / totalTxTime.GetSeconds ()));
th.m_ori = ori;
th.m_mtl = mtl;
station->m_thresholds.push_back (std::make_pair (th, mode));

View File

@@ -257,7 +257,7 @@ WifiMacHeader::SetType (WifiMacType type)
void
WifiMacHeader::SetDuration (Time duration)
{
int64_t duration_us = ceil (static_cast<double> (duration.GetNanoSeconds ()) / 1000);
int64_t duration_us = static_cast<int64_t> (ceil (static_cast<double> (duration.GetNanoSeconds ()) / 1000));
NS_ASSERT (duration_us >= 0 && duration_us <= 0x7fff);
m_duration = static_cast<uint16_t> (duration_us);
}

View File

@@ -162,7 +162,7 @@ WifiMode::GetDataRate (uint16_t channelWidth, uint16_t guardInterval, uint8_t ns
uint16_t usableSubCarriers = 0;
double symbolRate = 0;
double codingRate = 0;
uint16_t numberOfBitsPerSubcarrier = log2 (GetConstellationSize ());
uint16_t numberOfBitsPerSubcarrier = static_cast<uint16_t> (log2 (GetConstellationSize ()));
if (item->modClass == WIFI_MOD_CLASS_DSSS)
{
dataRate = ((11000000 / 11) * numberOfBitsPerSubcarrier);
@@ -799,7 +799,7 @@ WifiModeFactory::AllocateUid (std::string uniqueUid)
}
j++;
}
uint32_t uid = m_itemList.size ();
uint32_t uid = static_cast<uint32_t> (m_itemList.size ());
m_itemList.push_back (WifiModeItem ());
return uid;
}

View File

@@ -498,7 +498,7 @@ WifiNetDevice::SelectQueue (Ptr<QueueItem> item) const
// if the admission control were implemented, here we should check whether
// the access category assigned to the packet should be downgraded
return QosUtilsMapTidToAc (priority);
return static_cast<uint8_t> (QosUtilsMapTidToAc (priority));
}
} //namespace ns3

View File

@@ -47,7 +47,7 @@ void
WifiPhyTag::Serialize (TagBuffer i) const
{
i.Write ((uint8_t *)&m_wifiTxVector, sizeof (WifiTxVector));
i.WriteU16 (m_mpduType);
i.WriteU16 (static_cast<uint16_t> (m_mpduType));
i.WriteU8 (m_frameComplete);
}

View File

@@ -1311,7 +1311,7 @@ WifiPhy::GetMaxSupportedRxSpatialStreams (void) const
uint8_t
WifiPhy::GetNBssMembershipSelectors (void) const
{
return m_bssMembershipSelectorSet.size ();
return static_cast<uint8_t> (m_bssMembershipSelectorSet.size ());
}
uint8_t
@@ -2157,11 +2157,11 @@ WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, uint16_t freq
//Add signal extension for ERP PHY
if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
{
return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ()) + MicroSeconds (6);
return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ())) + MicroSeconds (6);
}
else
{
return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ());
return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ()));
}
}
case WIFI_MOD_CLASS_HT:
@@ -2171,11 +2171,11 @@ WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, uint16_t freq
&& ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
|| (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
{
return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ()) + MicroSeconds (6);
return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ())) + MicroSeconds (6);
}
else //at 5 GHz
{
return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ());
return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ()));
}
}
case WIFI_MOD_CLASS_HE:
@@ -2184,11 +2184,11 @@ WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, uint16_t freq
&& ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
|| (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
{
return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ()) + MicroSeconds (6);
return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ())) + MicroSeconds (6);
}
else //at 5 GHz
{
return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ());
return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ()));
}
}
case WIFI_MOD_CLASS_DSSS:
@@ -3494,7 +3494,7 @@ WifiPhy::IsMcsSupported (WifiMode mcs) const
uint8_t
WifiPhy::GetNModes (void) const
{
return m_deviceRateSet.size ();
return static_cast<uint8_t> (m_deviceRateSet.size ());
}
WifiMode
@@ -3506,7 +3506,7 @@ WifiPhy::GetMode (uint8_t mode) const
uint8_t
WifiPhy::GetNMcs (void) const
{
return m_deviceMcsSet.size ();
return static_cast<uint8_t> (m_deviceMcsSet.size ());
}
WifiMode

View File

@@ -302,22 +302,22 @@ WifiRadioEnergyModel::GetMaximumTimeInState (int state) const
switch (state)
{
case WifiPhyState::IDLE:
remainingTime = NanoSeconds (1e9 * (remainingEnergy / (m_idleCurrentA * supplyVoltage)));
remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_idleCurrentA * supplyVoltage))));
break;
case WifiPhyState::CCA_BUSY:
remainingTime = NanoSeconds (1e9 * (remainingEnergy / (m_ccaBusyCurrentA * supplyVoltage)));
remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_ccaBusyCurrentA * supplyVoltage))));
break;
case WifiPhyState::TX:
remainingTime = NanoSeconds (1e9 * (remainingEnergy / (m_txCurrentA * supplyVoltage)));
remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_txCurrentA * supplyVoltage))));
break;
case WifiPhyState::RX:
remainingTime = NanoSeconds (1e9 * (remainingEnergy / (m_rxCurrentA * supplyVoltage)));
remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_rxCurrentA * supplyVoltage))));
break;
case WifiPhyState::SWITCHING:
remainingTime = NanoSeconds (1e9 * (remainingEnergy / (m_switchingCurrentA * supplyVoltage)));
remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_switchingCurrentA * supplyVoltage))));
break;
case WifiPhyState::SLEEP:
remainingTime = NanoSeconds (1e9 * (remainingEnergy / (m_sleepCurrentA * supplyVoltage)));
remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_sleepCurrentA * supplyVoltage))));
break;
default:
NS_FATAL_ERROR ("WifiRadioEnergyModel: undefined radio state " << state);

View File

@@ -1615,7 +1615,7 @@ WifiRemoteStationManager::LookupState (Mac48Address address) const
state->m_operationalMcsSet.push_back (GetDefaultMcs ());
state->m_channelWidth = m_wifiPhy->GetChannelWidth ();
state->m_shortGuardInterval = m_wifiPhy->GetShortGuardInterval ();
state->m_guardInterval = m_wifiPhy->GetGuardInterval ().GetNanoSeconds ();
state->m_guardInterval = static_cast<uint16_t> (m_wifiPhy->GetGuardInterval ().GetNanoSeconds ());
state->m_greenfield = m_wifiPhy->GetGreenfield ();
state->m_streams = 1;
state->m_ness = 0;
@@ -1861,7 +1861,7 @@ WifiRemoteStationManager::AddBasicMode (WifiMode mode)
uint8_t
WifiRemoteStationManager::GetNBasicModes (void) const
{
return m_bssBasicRateSet.size ();
return static_cast<uint8_t> (m_bssBasicRateSet.size ());
}
WifiMode
@@ -1928,7 +1928,7 @@ WifiRemoteStationManager::AddBasicMcs (WifiMode mcs)
uint8_t
WifiRemoteStationManager::GetNBasicMcs (void) const
{
return m_bssBasicMcsSet.size ();
return static_cast<uint8_t> (m_bssBasicMcsSet.size ());
}
WifiMode
@@ -2097,7 +2097,7 @@ WifiRemoteStationManager::GetMac (void) const
uint8_t
WifiRemoteStationManager::GetNSupported (const WifiRemoteStation *station) const
{
return station->m_state->m_operationalRateSet.size ();
return static_cast<uint8_t> (station->m_state->m_operationalRateSet.size ());
}
bool
@@ -2127,7 +2127,7 @@ WifiRemoteStationManager::GetHeSupported (const WifiRemoteStation *station) cons
uint8_t
WifiRemoteStationManager::GetNMcsSupported (const WifiRemoteStation *station) const
{
return station->m_state->m_operationalMcsSet.size ();
return static_cast<uint8_t> (station->m_state->m_operationalMcsSet.size ());
}
uint32_t
@@ -2166,7 +2166,7 @@ WifiRemoteStationManager::GetNumberOfSupportedStreams (Mac48Address address) con
uint8_t
WifiRemoteStationManager::GetNMcsSupported (Mac48Address address) const
{
return LookupState (address)->m_operationalMcsSet.size ();
return static_cast<uint8_t> (LookupState (address)->m_operationalMcsSet.size ());
}
bool

View File

@@ -87,7 +87,7 @@ ConvertGuardIntervalToNanoSeconds (WifiMode mode, bool htShortGuardInterval, Tim
uint16_t gi;
if (mode.GetModulationClass () == WIFI_MOD_CLASS_HE)
{
gi = heGuardInterval.GetNanoSeconds ();
gi = static_cast<uint16_t> (heGuardInterval.GetNanoSeconds ());
}
else if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT || mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
{