Skip to content

Commit 9f28d30

Browse files
author
Alexandru Kampmann
committed
Revert "using at() instead of [] to ensure array bounds check (#23)"
This reverts commit 96060d9.
1 parent 96060d9 commit 9f28d30

23 files changed

+214
-226
lines changed

include/rtps/common/Locator.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ struct FullLengthLocator {
110110
inline FullLengthLocator
111111
getBuiltInUnicastLocator(ParticipantId_t participantId) {
112112
return FullLengthLocator::createUDPv4Locator(
113-
Config::IP_ADDRESS.at(0), Config::IP_ADDRESS.at(1), Config::IP_ADDRESS.at(2),
114-
Config::IP_ADDRESS.at(3), getBuiltInUnicastPort(participantId));
113+
Config::IP_ADDRESS[0], Config::IP_ADDRESS[1], Config::IP_ADDRESS[2],
114+
Config::IP_ADDRESS[3], getBuiltInUnicastPort(participantId));
115115
}
116116

117117
inline FullLengthLocator getBuiltInMulticastLocator() {
@@ -121,16 +121,16 @@ inline FullLengthLocator getBuiltInMulticastLocator() {
121121

122122
inline FullLengthLocator getUserUnicastLocator(ParticipantId_t participantId) {
123123
return FullLengthLocator::createUDPv4Locator(
124-
Config::IP_ADDRESS.at(0), Config::IP_ADDRESS.at(1), Config::IP_ADDRESS.at(2),
125-
Config::IP_ADDRESS.at(3), getUserUnicastPort(participantId));
124+
Config::IP_ADDRESS[0], Config::IP_ADDRESS[1], Config::IP_ADDRESS[2],
125+
Config::IP_ADDRESS[3], getUserUnicastPort(participantId));
126126
}
127127

128128
inline FullLengthLocator
129129
getUserMulticastLocator() { // this would be a unicastaddress, as
130130
// defined in config
131131
return FullLengthLocator::createUDPv4Locator(
132-
Config::IP_ADDRESS.at(0), Config::IP_ADDRESS.at(1), Config::IP_ADDRESS.at(2),
133-
Config::IP_ADDRESS.at(3), getUserMulticastPort());
132+
Config::IP_ADDRESS[0], Config::IP_ADDRESS[1], Config::IP_ADDRESS[2],
133+
Config::IP_ADDRESS[3], getUserMulticastPort());
134134
}
135135

136136
inline FullLengthLocator getDefaultSendMulticastLocator() {
@@ -148,16 +148,16 @@ struct LocatorIPv4 {
148148

149149
LocatorIPv4() = default;
150150
LocatorIPv4(const FullLengthLocator &locator) {
151-
address.at(0) = locator.address[12];
152-
address.at(1) = locator.address[13];
153-
address.at(2) = locator.address[14];
154-
address.at(3) = locator.address[15];
151+
address[0] = locator.address[12];
152+
address[1] = locator.address[13];
153+
address[2] = locator.address[14];
154+
address[3] = locator.address[15];
155155
port = locator.port;
156156
kind = locator.kind;
157157
}
158158

159159
ip4_addr_t getIp4Address() const {
160-
return transformIP4ToU32(address.at(0), address.at(1), address.at(2), address.at(3));
160+
return transformIP4ToU32(address[0], address[1], address[2], address[3]);
161161
}
162162

163163
void setInvalid() { kind = LocatorKind_t::LOCATOR_KIND_INVALID; }

include/rtps/config_aurix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ const uint8_t NUM_READERS_PER_PARTICIPANT = 4;
5050
const uint8_t NUM_WRITER_PROXIES_PER_READER = 3;
5151
const uint8_t NUM_READER_PROXIES_PER_WRITER = 3;
5252

53-
const uint32_t MAX_NUM_UNMATCHED_REMOTE_WRITERS = 100;
54-
const uint32_t MAX_NUM_UNMATCHED_REMOTE_READERS = 10;
53+
const uint8_t MAX_NUM_UNMATCHED_REMOTE_WRITERS = 100;
54+
const uint8_t MAX_NUM_UNMATCHED_REMOTE_READERS = 10;
5555

5656
const uint8_t HISTORY_SIZE = 10;
5757

include/rtps/config_desktop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ const uint8_t NUM_READERS_PER_PARTICIPANT = 4;
5454
const uint8_t NUM_WRITER_PROXIES_PER_READER = 3;
5555
const uint8_t NUM_READER_PROXIES_PER_WRITER = 3;
5656

57-
const uint32_t MAX_NUM_UNMATCHED_REMOTE_WRITERS = 100;
58-
const uint32_t MAX_NUM_UNMATCHED_REMOTE_READERS = 10;
57+
const uint8_t MAX_NUM_UNMATCHED_REMOTE_WRITERS = 100;
58+
const uint8_t MAX_NUM_UNMATCHED_REMOTE_READERS = 10;
5959

6060
const uint8_t HISTORY_SIZE = 10;
6161

include/rtps/config_r5.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const uint8_t NUM_READERS_PER_PARTICIPANT =
2626
const uint8_t NUM_WRITER_PROXIES_PER_READER = 60;
2727
const uint8_t NUM_READER_PROXIES_PER_WRITER = 60;
2828

29-
const uint32_t MAX_NUM_UNMATCHED_REMOTE_WRITERS = 150;
30-
const uint32_t MAX_NUM_UNMATCHED_REMOTE_READERS = 150;
29+
const uint8_t MAX_NUM_UNMATCHED_REMOTE_WRITERS = 150;
30+
const uint8_t MAX_NUM_UNMATCHED_REMOTE_READERS = 150;
3131

3232
const uint8_t MAX_NUM_READER_CALLBACKS = 5;
3333

include/rtps/config_stm.h

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace rtps {
3737
namespace Config {
3838
const VendorId_t VENDOR_ID = {13, 37};
3939
const std::array<uint8_t, 4> IP_ADDRESS = {
40-
192, 168, 1, 103}; // Needs to be set in lwipcfg.h too.
40+
192, 168, 0, 66}; // Needs to be set in lwipcfg.h too.
4141
const GuidPrefix_t BASE_GUID_PREFIX{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12};
4242

4343
const uint8_t DOMAIN_ID = 0; // 230 possible with UDP
@@ -51,14 +51,7 @@ const uint8_t NUM_READERS_PER_PARTICIPANT = 4;
5151
const uint8_t NUM_WRITER_PROXIES_PER_READER = 3;
5252
const uint8_t NUM_READER_PROXIES_PER_WRITER = 3;
5353

54-
const uint8_t MAX_NUM_UNMATCHED_REMOTE_WRITERS = 15;
55-
const uint8_t MAX_NUM_UNMATCHED_REMOTE_READERS = 15;
56-
57-
const uint8_t MAX_NUM_READER_CALLBACKS = 5;
58-
59-
60-
const uint8_t HISTORY_SIZE_STATELESS = 2;
61-
const uint8_t HISTORY_SIZE_STATEFUL = 10;
54+
const uint8_t HISTORY_SIZE = 10;
6255

6356
const uint8_t MAX_TYPENAME_LENGTH = 20;
6457
const uint8_t MAX_TOPICNAME_LENGTH = 20;
@@ -69,27 +62,20 @@ const int THREAD_POOL_READER_STACKSIZE = 1600; // byte
6962
const uint16_t SPDP_WRITER_STACKSIZE = 550; // byte
7063

7164
const uint16_t SF_WRITER_HB_PERIOD_MS = 4000;
72-
const uint16_t SPDP_RESEND_PERIOD_MS = 1000;
65+
const uint16_t SPDP_RESEND_PERIOD_MS = 10000;
7366
const uint8_t SPDP_CYCLECOUNT_HEARTBEAT =
7467
2; // skip x SPDP rounds before checking liveliness
75-
const uint8_t SPDP_WRITER_PRIO = 24;
68+
const uint8_t SPDP_WRITER_PRIO = 3;
7669
const uint8_t SPDP_MAX_NUMBER_FOUND_PARTICIPANTS = 5;
77-
const uint8_t SPDP_MAX_NUM_LOCATORS = 1;
78-
const Duration_t SPDP_DEFAULT_REMOTE_LEASE_DURATION = {
79-
100, 0}; // Default lease duration for remote participants, usually
80-
// overwritten by remote info
81-
const Duration_t SPDP_MAX_REMOTE_LEASE_DURATION = {
82-
180,
83-
0}; // Absolute maximum lease duration, ignoring remote participant info
84-
70+
const uint8_t SPDP_MAX_NUM_LOCATORS = 5;
8571
const Duration_t SPDP_LEASE_DURATION = {100, 0};
8672

8773
const int MAX_NUM_UDP_CONNECTIONS = 10;
8874

8975
const int THREAD_POOL_NUM_WRITERS = 1;
9076
const int THREAD_POOL_NUM_READERS = 1;
91-
const int THREAD_POOL_WRITER_PRIO = 24;
92-
const int THREAD_POOL_READER_PRIO = 24;
77+
const int THREAD_POOL_WRITER_PRIO = 3;
78+
const int THREAD_POOL_READER_PRIO = 3;
9379
const int THREAD_POOL_WORKLOAD_QUEUE_LENGTH = 10;
9480

9581
constexpr int OVERALL_HEAP_SIZE =

include/rtps/discovery/SEDPAgent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class SEDPAgent {
6060
private:
6161
Participant *m_part;
6262
SemaphoreHandle_t m_mutex;
63-
std::array<uint8_t, 600> m_buffer; // TODO check size, currently changed from 300 to 600
63+
uint8_t m_buffer[600]; // TODO check size, currently changed from 300 to 600
6464
// (FastDDS gives too many options)
6565
BuiltInEndpoints m_endpoints;
6666
/*

include/rtps/discovery/TopicData.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ struct BuiltInTopicKey {
4141

4242
struct TopicData {
4343
Guid_t endpointGuid;
44-
std::array<char, Config::MAX_TYPENAME_LENGTH> typeName;
45-
std::array<char, Config::MAX_TOPICNAME_LENGTH> topicName;
44+
char typeName[Config::MAX_TYPENAME_LENGTH];
45+
char topicName[Config::MAX_TOPICNAME_LENGTH];
4646
ReliabilityKind_t reliabilityKind;
4747
DurabilityKind_t durabilityKind;
4848
FullLengthLocator unicastLocator;
@@ -93,8 +93,8 @@ struct TopicDataCompressed {
9393
TopicDataCompressed(const TopicData &topic_data) {
9494
endpointGuid = topic_data.endpointGuid;
9595
topicHash =
96-
hashCharArray(topic_data.topicName.data(), topic_data.topicName.size());
97-
typeHash = hashCharArray(topic_data.typeName.data(),topic_data.typeName.size());
96+
hashCharArray(topic_data.topicName, Config::MAX_TOPICNAME_LENGTH);
97+
typeHash = hashCharArray(topic_data.typeName, Config::MAX_TYPENAME_LENGTH);
9898
is_reliable = (topic_data.reliabilityKind == ReliabilityKind_t::RELIABLE)
9999
? true
100100
: false;

include/rtps/entities/Domain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class Domain {
7676
std::array<StatefulWriter, Config::NUM_STATEFUL_WRITERS> m_statefulWriters;
7777
template <typename A, typename B> B *getNextUnusedEndpoint(A &a) {
7878
for (unsigned int i = 0; i < a.size(); i++) {
79-
if (!a.at(i).isInitialized()) {
80-
return &(a.at(i));
79+
if (!a[i].isInitialized()) {
80+
return &(a[i]);
8181
}
8282
}
8383
return nullptr;

include/rtps/entities/StatefulReader.tpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Author: i11 - Embedded Software, RWTH Aachen University
3333
#include "rtps/utils/printutils.h"
3434
#define SFR_LOG(...) \
3535
if (true) { \
36-
printf("[StatefulReader %s] ", m_attributes.topicName.data()); \
36+
printf("[StatefulReader %s] ", &m_attributes.topicName[0]); \
3737
printf(__VA_ARGS__); \
3838
printf("\n"); \
3939
}
@@ -148,7 +148,7 @@ bool StatefulReaderT<NetworkDriver>::onNewGapMessage(
148148
SequenceNumberSet set;
149149
set.numBits = 1;
150150
set.base = writer->expectedSN;
151-
set.bitMap.at(0) = uint32_t{1} << 31;
151+
set.bitMap[0] = uint32_t{1} << 31;
152152
rtps::MessageFactory::addAckNack(info.buffer, msg.writerId, msg.readerId, set,
153153
writer->getNextAckNackCount(), false);
154154
m_transport->sendPacket(info);

include/rtps/entities/StatefulWriter.tpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ using rtps::StatefulWriterT;
3636
#include "rtps/utils/printutils.h"
3737
#define SFW_LOG(...) \
3838
if (true) { \
39-
printf("[Stateful Writer %s] ", this->m_attributes.topicName.data()); \
39+
printf("[Stateful Writer %s] ", this->m_attributes.topicName); \
4040
printf(__VA_ARGS__); \
4141
printf("\n"); \
4242
}
@@ -423,7 +423,7 @@ void StatefulWriterT<NetworkDriver>::sendHeartBeat() {
423423
}
424424
if (firstSN == SEQUENCENUMBER_UNKNOWN || lastSN == SEQUENCENUMBER_UNKNOWN) {
425425

426-
if (strlen(&this->m_attributes.typeName.at(0)) != 0) {
426+
if (strlen(&this->m_attributes.typeName[0]) != 0) {
427427
SFW_LOG("Skipping heartbeat. No data.\n");
428428
}
429429
return;

0 commit comments

Comments
 (0)