Skip to content

Commit 113b80f

Browse files
committed
Cast all std::vector.size() returns in the RVC service area delegate to uint32_t. The service area server limits the size of these lists to 255.
1 parent e2ef26e commit 113b80f

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

examples/rvc-app/rvc-common/src/rvc-service-area-delegate.cpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ bool RvcServiceAreaDelegate::IsSupportedLocationsChangeAllowed()
109109

110110
uint32_t RvcServiceAreaDelegate::GetNumberOfSupportedLocations()
111111
{
112-
return mSupportedLocations.size();
112+
return (uint32_t)mSupportedLocations.size();
113113
}
114114

115115
bool RvcServiceAreaDelegate::GetSupportedLocationByIndex(uint32_t listIndex, LocationStructureWrapper & aSupportedLocation)
116116
{
117117
bool ret_value = false;
118118

119-
if (listIndex < mSupportedLocations.size())
119+
if (listIndex < (uint32_t)mSupportedLocations.size())
120120
{
121121
aSupportedLocation = mSupportedLocations[listIndex];
122122
ret_value = true;
@@ -134,7 +134,7 @@ bool RvcServiceAreaDelegate::GetSupportedLocationById(uint32_t aLocationId, uint
134134
bool ret_value = false;
135135

136136
listIndex = 0;
137-
uint32_t listSize = mSupportedLocations.size();
137+
uint32_t listSize = (uint32_t)mSupportedLocations.size();
138138

139139
while (listIndex < listSize)
140140
{
@@ -159,11 +159,11 @@ bool RvcServiceAreaDelegate::AddSupportedLocation(const LocationStructureWrapper
159159
// etc.
160160

161161
// Double-check list size to ensure there no memory issues.
162-
if (mSupportedLocations.size() < kMaxNumSupportedLocations)
162+
if ((uint32_t)mSupportedLocations.size() < kMaxNumSupportedLocations)
163163
{
164164
// not sorting list, number of locations normally expected to be small, max 255
165165
mSupportedLocations.push_back(newLocation);
166-
listIndex = mSupportedMaps.size() - 1; // new element is last in list
166+
listIndex = (uint32_t)mSupportedMaps.size() - 1; // new element is last in list
167167
ret_value = true;
168168
}
169169
else
@@ -200,7 +200,7 @@ bool RvcServiceAreaDelegate::ClearSupportedLocations()
200200
{
201201
bool ret_value = false;
202202

203-
if (mSupportedLocations.size() > 0)
203+
if ((uint32_t)mSupportedLocations.size() > 0)
204204
{
205205
mSupportedLocations.clear();
206206
ret_value = true;
@@ -219,14 +219,14 @@ bool RvcServiceAreaDelegate::IsSupportedMapChangeAllowed()
219219

220220
uint32_t RvcServiceAreaDelegate::GetNumberOfSupportedMaps()
221221
{
222-
return mSupportedMaps.size();
222+
return (uint32_t)mSupportedMaps.size();
223223
}
224224

225225
bool RvcServiceAreaDelegate::GetSupportedMapByIndex(uint32_t listIndex, MapStructureWrapper & aSupportedMap)
226226
{
227227
bool ret_value = false;
228228

229-
if (listIndex < mSupportedMaps.size())
229+
if (listIndex < (uint32_t)mSupportedMaps.size())
230230
{
231231
aSupportedMap = mSupportedMaps[listIndex];
232232
ret_value = true;
@@ -243,7 +243,7 @@ bool RvcServiceAreaDelegate::GetSupportedMapById(uint8_t aMapId, uint32_t & list
243243
bool ret_value = false;
244244

245245
listIndex = 0;
246-
uint32_t listSize = mSupportedMaps.size();
246+
uint32_t listSize = (uint32_t)mSupportedMaps.size();
247247

248248
while (listIndex < listSize)
249249
{
@@ -268,11 +268,11 @@ bool RvcServiceAreaDelegate::AddSupportedMap(const MapStructureWrapper & newMap,
268268
// etc.
269269

270270
// Double-check list size to ensure there no memory issues.
271-
if (mSupportedMaps.size() < kMaxNumSupportedMaps)
271+
if ((uint32_t)mSupportedMaps.size() < kMaxNumSupportedMaps)
272272
{
273273
// not sorting list, number of locations normally expected to be small, max 255
274274
mSupportedMaps.push_back(newMap);
275-
listIndex = mSupportedMaps.size() - 1; // new element is last in list
275+
listIndex = (uint32_t)mSupportedMaps.size() - 1; // new element is last in list
276276
}
277277
else
278278
{
@@ -307,7 +307,7 @@ bool RvcServiceAreaDelegate::ClearSupportedMaps()
307307
{
308308
bool ret_value = false;
309309

310-
if (mSupportedMaps.size() > 0)
310+
if ((uint32_t)mSupportedMaps.size() > 0)
311311
{
312312
mSupportedMaps.clear();
313313
ret_value = true;
@@ -321,14 +321,14 @@ bool RvcServiceAreaDelegate::ClearSupportedMaps()
321321

322322
uint32_t RvcServiceAreaDelegate::GetNumberOfSelectedLocations()
323323
{
324-
return mSelectedLocations.size();
324+
return (uint32_t)mSelectedLocations.size();
325325
}
326326

327327
bool RvcServiceAreaDelegate::GetSelectedLocationByIndex(uint32_t listIndex, uint32_t & aSelectedLocation)
328328
{
329329
bool ret_value = false;
330330

331-
if (listIndex < mSelectedLocations.size())
331+
if (listIndex < (uint32_t)mSelectedLocations.size())
332332
{
333333
aSelectedLocation = mSelectedLocations[listIndex];
334334
ret_value = true;
@@ -345,11 +345,11 @@ bool RvcServiceAreaDelegate::AddSelectedLocation(uint32_t aLocationId, uint32_t
345345
// etc.
346346

347347
// Double-check list size to ensure there no memory issues.
348-
if (mSelectedLocations.size() < kMaxNumSelectedLocations)
348+
if ((uint32_t)mSelectedLocations.size() < kMaxNumSelectedLocations)
349349
{
350350
// not sorting list, number of locations normally expected to be small, max 255
351351
mSelectedLocations.push_back(aLocationId);
352-
listIndex = mSelectedLocations.size() - 1; // new element is last in list
352+
listIndex = (uint32_t)mSelectedLocations.size() - 1; // new element is last in list
353353
}
354354
else
355355
{
@@ -364,7 +364,7 @@ bool RvcServiceAreaDelegate::ClearSelectedLocations()
364364
{
365365
bool ret_value = false;
366366

367-
if (mSelectedLocations.size() > 0)
367+
if ((uint32_t)mSelectedLocations.size() > 0)
368368
{
369369
mSelectedLocations.clear();
370370
ret_value = true;
@@ -378,14 +378,14 @@ bool RvcServiceAreaDelegate::ClearSelectedLocations()
378378

379379
uint32_t RvcServiceAreaDelegate::GetNumberOfProgressElements()
380380
{
381-
return mProgressList.size();
381+
return (uint32_t)mProgressList.size();
382382
}
383383

384384
bool RvcServiceAreaDelegate::GetProgressElementByIndex(uint32_t listIndex, Structs::ProgressStruct::Type & aProgressElement)
385385
{
386386
bool ret_value = false;
387387

388-
if (listIndex < mProgressList.size())
388+
if (listIndex < (uint32_t)mProgressList.size())
389389
{
390390
aProgressElement = mProgressList[listIndex];
391391
ret_value = true;
@@ -403,7 +403,7 @@ bool RvcServiceAreaDelegate::GetProgressElementById(uint32_t aLocationId, uint32
403403
bool ret_value = false;
404404

405405
listIndex = 0;
406-
uint32_t listSize = mProgressList.size();
406+
uint32_t listSize = (uint32_t)mProgressList.size();
407407

408408
while (listIndex < listSize)
409409
{
@@ -428,11 +428,11 @@ bool RvcServiceAreaDelegate::AddProgressElement(const Structs::ProgressStruct::T
428428
// etc.
429429

430430
// Double-check list size to ensure there no memory issues.
431-
if (mProgressList.size() < kMaxNumProgressElements)
431+
if ((uint32_t)mProgressList.size() < kMaxNumProgressElements)
432432
{
433433
// not sorting list, number of locations normally expected to be small, max 255
434434
mProgressList.push_back(newProgressElement);
435-
listIndex = mProgressList.size() - 1; // new element is last in list
435+
listIndex = (uint32_t)mProgressList.size() - 1; // new element is last in list
436436
}
437437
else
438438
{
@@ -457,7 +457,7 @@ bool RvcServiceAreaDelegate::ClearProgress()
457457
{
458458
bool ret_value = false;
459459

460-
if (mProgressList.size() > 0)
460+
if ((uint32_t)mProgressList.size() > 0)
461461
{
462462
mProgressList.clear();
463463
ret_value = true;

0 commit comments

Comments
 (0)