Skip to content

Commit 8adca5d

Browse files
author
Stefano Avallone
committed
Fix misuse of Create<>() function
If Create<>() is used to create an object of an Object subclass, attributes are not initialized.
1 parent f315c12 commit 8adca5d

17 files changed

+35
-34
lines changed

src/buildings/test/buildings-channel-condition-model-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ BuildingsChannelConditionModelTestCase::DoRun()
104104

105105
Ptr<BuildingsChannelConditionModel> condModel = CreateObject<BuildingsChannelConditionModel>();
106106

107-
Ptr<Building> building = Create<Building>();
107+
auto building = CreateObject<Building>();
108108
building->SetNRoomsX(1);
109109
building->SetNRoomsY(1);
110110
building->SetNFloors(1);

src/buildings/test/buildings-penetration-loss-pathloss-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ BuildingsPenetrationLossesTestCase::DoRun()
174174
// create the factory for the propagation loss model
175175
ObjectFactory propModelFactory;
176176

177-
Ptr<Building> building = Create<Building>();
177+
auto building = CreateObject<Building>();
178178
building->SetExtWallsType(Building::ExtWallsType_t::ConcreteWithWindows);
179179
building->SetNRoomsX(1);
180180
building->SetNRoomsY(1);

src/buildings/test/three-gpp-v2v-channel-condition-model-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ ThreeGppV2vBuildingsChCondModelTestCase::DoRun()
136136
Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel>();
137137
nodes.Get(1)->AggregateObject(b);
138138

139-
Ptr<Building> building = Create<Building>();
139+
auto building = CreateObject<Building>();
140140
building->SetNRoomsX(1);
141141
building->SetNRoomsY(1);
142142
building->SetNFloors(1);

src/core/test/attribute-test-suite.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ PointerAttributeTestCase::DoRun()
18801880
// Now, lets create an Object of type Derived and set the local Ptr to point
18811881
// to that object. We can then set the PointerValue Attribute to that Ptr.
18821882
//
1883-
derived = Create<Derived>();
1883+
derived = CreateObject<Derived>();
18841884
bool ok = p->SetAttributeFailSafe("Pointer", PointerValue(derived));
18851885
NS_TEST_ASSERT_MSG_EQ(ok,
18861886
true,

src/flow-monitor/helper/flow-monitor-helper.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,16 @@ FlowMonitorHelper::Install(Ptr<Node> node)
8585
Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol>();
8686
if (ipv4)
8787
{
88-
Ptr<Ipv4FlowProbe> probe =
89-
Create<Ipv4FlowProbe>(monitor, DynamicCast<Ipv4FlowClassifier>(classifier), node);
88+
auto probe =
89+
CreateObject<Ipv4FlowProbe>(monitor, DynamicCast<Ipv4FlowClassifier>(classifier), node);
9090
}
9191
Ptr<FlowClassifier> classifier6 = GetClassifier6();
9292
Ptr<Ipv6L3Protocol> ipv6 = node->GetObject<Ipv6L3Protocol>();
9393
if (ipv6)
9494
{
95-
Ptr<Ipv6FlowProbe> probe6 =
96-
Create<Ipv6FlowProbe>(monitor, DynamicCast<Ipv6FlowClassifier>(classifier6), node);
95+
auto probe6 = CreateObject<Ipv6FlowProbe>(monitor,
96+
DynamicCast<Ipv6FlowClassifier>(classifier6),
97+
node);
9798
}
9899
return m_flowMonitor;
99100
}

src/lte/examples/lena-rem-sector-antenna.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ main(int argc, char* argv[])
7070
std::vector<Vector> enbPosition;
7171
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
7272
Ptr<Building> building;
73-
building = Create<Building>();
73+
building = CreateObject<Building>();
7474
building->SetBoundaries(
7575
Box(0.0, nRooms * roomLength, 0.0, nRooms * roomLength, 0.0, roomHeight));
7676
building->SetBuildingType(Building::Residential);

src/mpi/model/remote-channel-bundle-manager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ RemoteChannelBundleManager::Add(uint32_t systemId)
4848
NS_ASSERT(!g_initialized);
4949
NS_ASSERT(g_remoteChannelBundles.find(systemId) == g_remoteChannelBundles.end());
5050

51-
Ptr<RemoteChannelBundle> remoteChannelBundle = Create<RemoteChannelBundle>(systemId);
51+
auto remoteChannelBundle = CreateObject<RemoteChannelBundle>(systemId);
5252

5353
g_remoteChannelBundles[systemId] = remoteChannelBundle;
5454

src/network/utils/packet-burst.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Ptr<PacketBurst>
5656
PacketBurst::Copy() const
5757
{
5858
NS_LOG_FUNCTION(this);
59-
Ptr<PacketBurst> burst = Create<PacketBurst>();
59+
Ptr<PacketBurst> burst = CreateObject<PacketBurst>();
6060

6161
for (auto iter = m_packets.begin(); iter != m_packets.end(); ++iter)
6262
{

src/olsr/examples/olsr-hna.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ main(int argc, char* argv[])
237237
{
238238
// Create a special Ipv4StaticRouting instance for RoutingTableAssociation
239239
// Even the Ipv4StaticRouting instance added to list may be used
240-
Ptr<Ipv4StaticRouting> hnaEntries = Create<Ipv4StaticRouting>();
240+
Ptr<Ipv4StaticRouting> hnaEntries = CreateObject<Ipv4StaticRouting>();
241241

242242
// Add the required routes into the Ipv4StaticRouting Protocol instance
243243
// and have the node generate HNA messages for all these routes

src/olsr/model/olsr-routing-protocol.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ RoutingProtocol::RoutingProtocol()
252252
{
253253
m_uniformRandomVariable = CreateObject<UniformRandomVariable>();
254254

255-
m_hnaRoutingTable = Create<Ipv4StaticRouting>();
255+
m_hnaRoutingTable = CreateObject<Ipv4StaticRouting>();
256256
}
257257

258258
RoutingProtocol::~RoutingProtocol()

src/wifi/test/wifi-mac-ofdma-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2231,7 +2231,7 @@ OfdmaAckSequenceTest::DoRun()
22312231
{
22322232
// create a listening VHT station
22332233
wifi.SetStandard(WIFI_STANDARD_80211ac);
2234-
wifi.Install(phy, mac, Create<Node>());
2234+
wifi.Install(phy, mac, CreateObject<Node>());
22352235
}
22362236
22372237
wifi.SetStandard(m_scenario == WifiOfdmaScenario::HE ? WIFI_STANDARD_80211ax

src/wimax/model/bs-net-device.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ BaseStationNetDevice::DoSend(Ptr<Packet> packet,
622622
const Mac48Address& dest,
623623
uint16_t protocolNumber)
624624
{
625-
Ptr<PacketBurst> burst = Create<PacketBurst>();
625+
Ptr<PacketBurst> burst = CreateObject<PacketBurst>();
626626
ServiceFlow* serviceFlow = nullptr;
627627

628628
NS_LOG_INFO("BS (" << source << "):");

src/wimax/model/bs-scheduler-rtps.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ BSSchedulerRtps::CreateUgsBurst(ServiceFlow* serviceFlow,
164164
Time timeStamp;
165165
GenericMacHeader hdr;
166166
Ptr<Packet> packet;
167-
Ptr<PacketBurst> burst = Create<PacketBurst>();
167+
auto burst = CreateObject<PacketBurst>();
168168
uint32_t nrSymbolsRequired = 0;
169169

170170
// serviceFlow->CleanUpQueue ();
@@ -211,7 +211,7 @@ BSSchedulerRtps::BSSchedulerBroadcastConnection(uint32_t& availableSymbols)
211211
uint32_t nrSymbolsRequired = 0;
212212
GenericMacHeader hdr;
213213
Ptr<Packet> packet;
214-
Ptr<PacketBurst> burst = Create<PacketBurst>();
214+
auto burst = CreateObject<PacketBurst>();
215215

216216
while (GetBs()->GetBroadcastConnection()->HasPackets() && availableSymbols > 0)
217217
{
@@ -258,7 +258,7 @@ BSSchedulerRtps::BSSchedulerInitialRangingConnection(uint32_t& availableSymbols)
258258
uint32_t nrSymbolsRequired = 0;
259259
GenericMacHeader hdr;
260260
Ptr<Packet> packet;
261-
Ptr<PacketBurst> burst = Create<PacketBurst>();
261+
auto burst = CreateObject<PacketBurst>();
262262

263263
while (GetBs()->GetInitialRangingConnection()->HasPackets() && availableSymbols > 0)
264264
{
@@ -306,7 +306,7 @@ BSSchedulerRtps::BSSchedulerBasicConnection(uint32_t& availableSymbols)
306306
uint32_t nrSymbolsRequired = 0;
307307
GenericMacHeader hdr;
308308
Ptr<Packet> packet;
309-
Ptr<PacketBurst> burst = Create<PacketBurst>();
309+
auto burst = CreateObject<PacketBurst>();
310310

311311
std::vector<Ptr<WimaxConnection>> connections;
312312

@@ -353,7 +353,7 @@ BSSchedulerRtps::BSSchedulerBasicConnection(uint32_t& availableSymbols)
353353
if (burst->GetNPackets() != 0)
354354
{
355355
AddDownlinkBurst(connection, diuc, modulationType, burst);
356-
burst = Create<PacketBurst>();
356+
burst = CreateObject<PacketBurst>();
357357
}
358358
}
359359
}
@@ -367,7 +367,7 @@ BSSchedulerRtps::BSSchedulerPrimaryConnection(uint32_t& availableSymbols)
367367
uint32_t nrSymbolsRequired = 0;
368368
GenericMacHeader hdr;
369369
Ptr<Packet> packet;
370-
Ptr<PacketBurst> burst = Create<PacketBurst>();
370+
auto burst = CreateObject<PacketBurst>();
371371

372372
std::vector<Ptr<WimaxConnection>> connections;
373373

@@ -427,7 +427,7 @@ BSSchedulerRtps::BSSchedulerUGSConnection(uint32_t& availableSymbols)
427427
uint32_t nrSymbolsRequired = 0;
428428
GenericMacHeader hdr;
429429
Ptr<Packet> packet;
430-
Ptr<PacketBurst> burst = Create<PacketBurst>();
430+
auto burst = CreateObject<PacketBurst>();
431431

432432
Time currentTime = Simulator::Now();
433433

@@ -471,7 +471,7 @@ BSSchedulerRtps::BSSchedulerUGSConnection(uint32_t& availableSymbols)
471471
AddDownlinkBurst(connection, diuc, modulationType, burst);
472472
currentTime = Simulator::Now();
473473
serviceFlowRecord->SetDlTimeStamp(currentTime);
474-
burst = Create<PacketBurst>();
474+
burst = CreateObject<PacketBurst>();
475475
}
476476
}
477477
}
@@ -484,7 +484,7 @@ BSSchedulerRtps::BSSchedulerRTPSConnection(uint32_t& availableSymbols)
484484
Ptr<WimaxConnection> connection;
485485
GenericMacHeader hdr;
486486
Ptr<Packet> packet;
487-
Ptr<PacketBurst> burst = Create<PacketBurst>();
487+
auto burst = CreateObject<PacketBurst>();
488488

489489
Time currentTime = Simulator::Now();
490490

@@ -569,7 +569,7 @@ BSSchedulerRtps::BSSchedulerRTPSConnection(uint32_t& availableSymbols)
569569
{
570570
packet = rtPSConnection[i]->GetQueue()->Peek(hdr);
571571
uint32_t symbolsForPacketTransmission = 0;
572-
burst = Create<PacketBurst>();
572+
burst = CreateObject<PacketBurst>();
573573
NS_LOG_INFO("\t\tCID = " << rtPSConnection[i]->GetCid()
574574
<< " assignedSymbols = " << symbolsRequired[i]);
575575

@@ -627,7 +627,7 @@ BSSchedulerRtps::BSSchedulerNRTPSConnection(uint32_t& availableSymbols)
627627
uint32_t nrSymbolsRequired = 0;
628628
GenericMacHeader hdr;
629629
Ptr<Packet> packet;
630-
Ptr<PacketBurst> burst = Create<PacketBurst>();
630+
auto burst = CreateObject<PacketBurst>();
631631

632632
std::vector<ServiceFlow*> serviceFlows;
633633

@@ -670,7 +670,7 @@ BSSchedulerRtps::BSSchedulerNRTPSConnection(uint32_t& availableSymbols)
670670
if (burst->GetNPackets() != 0)
671671
{
672672
AddDownlinkBurst(connection, diuc, modulationType, burst);
673-
burst = Create<PacketBurst>();
673+
burst = CreateObject<PacketBurst>();
674674
}
675675
}
676676
}
@@ -684,7 +684,7 @@ BSSchedulerRtps::BSSchedulerBEConnection(uint32_t& availableSymbols)
684684
uint32_t nrSymbolsRequired = 0;
685685
GenericMacHeader hdr;
686686
Ptr<Packet> packet;
687-
Ptr<PacketBurst> burst = Create<PacketBurst>();
687+
auto burst = CreateObject<PacketBurst>();
688688

689689
std::vector<ServiceFlow*> serviceFlows;
690690

@@ -726,7 +726,7 @@ BSSchedulerRtps::BSSchedulerBEConnection(uint32_t& availableSymbols)
726726
if (burst->GetNPackets() != 0)
727727
{
728728
AddDownlinkBurst(connection, diuc, modulationType, burst);
729-
burst = Create<PacketBurst>();
729+
burst = CreateObject<PacketBurst>();
730730
}
731731
}
732732
}

src/wimax/model/bs-scheduler-simple.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ BSSchedulerSimple::Schedule()
175175
}
176176
else
177177
{
178-
burst = Create<PacketBurst>();
178+
burst = CreateObject<PacketBurst>();
179179
while (connection->HasPackets())
180180
{
181181
uint32_t FirstPacketSize = connection->GetQueue()->GetFirstPacketRequiredByte(
@@ -353,7 +353,7 @@ BSSchedulerSimple::CreateUgsBurst(ServiceFlow* serviceFlow,
353353
Time timeStamp;
354354
GenericMacHeader hdr;
355355
Ptr<Packet> packet;
356-
Ptr<PacketBurst> burst = Create<PacketBurst>();
356+
auto burst = CreateObject<PacketBurst>();
357357
uint32_t nrSymbolsRequired = 0;
358358

359359
// serviceFlow->CleanUpQueue ();

src/wimax/model/simple-ofdm-wimax-phy.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ SimpleOfdmWimaxPhy::ConvertBitsToBurst(Bvec buffer)
543543
j++;
544544
}
545545
uint16_t pos = 0;
546-
Ptr<PacketBurst> RecvBurst = Create<PacketBurst>();
546+
Ptr<PacketBurst> RecvBurst = CreateObject<PacketBurst>();
547547
while (pos < bufferSize)
548548
{
549549
uint16_t packetSize = 0;

src/wimax/model/ss-link-manager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ SSLinkManager::SendRangingRequest(uint8_t uiuc, uint16_t allocationSize)
202202
}
203203

204204
Ptr<Packet> packet = Create<Packet>();
205-
Ptr<PacketBurst> burst = Create<PacketBurst>();
205+
Ptr<PacketBurst> burst = CreateObject<PacketBurst>();
206206

207207
packet->AddHeader(m_rngreq);
208208
packet->AddHeader(ManagementMessageType(ManagementMessageType::MESSAGE_TYPE_RNG_REQ));

src/wimax/model/ss-scheduler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ SSScheduler::Schedule(uint16_t availableSymbols,
7070
Ptr<WimaxConnection>& connection)
7171
{
7272
Time timeStamp;
73-
Ptr<PacketBurst> burst = Create<PacketBurst>();
73+
Ptr<PacketBurst> burst = CreateObject<PacketBurst>();
7474
uint16_t nrSymbolsRequired = 0;
7575

7676
if (!connection)

0 commit comments

Comments
 (0)