Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inconsistent integer comparison warnings
- Loading branch information
1 parent
2eec997
commit 3b842a7
Showing
2 changed files
with
5 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,15 +49,15 @@ SettingsHierarchy::SettingsHierarchy(Settings *fallback) | |
|
||
Settings *SettingsHierarchy::getLayer(int layer) const | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
SmallJoker
Author
Member
|
||
{ | ||
if (layer < 0 || layer >= layers.size()) | ||
if (layer < 0 || layer >= (int)layers.size()) | ||
throw BaseException("Invalid settings layer"); | ||
return layers[layer]; | ||
} | ||
|
||
|
||
Settings *SettingsHierarchy::getParent(int layer) const | ||
{ | ||
assert(layer >= 0 && layer < layers.size()); | ||
assert(layer >= 0 && layer < (int)layers.size()); | ||
// iterate towards the origin (0) to find the next fallback layer | ||
for (int i = layer - 1; i >= 0; --i) { | ||
if (layers[i]) | ||
|
@@ -72,8 +72,8 @@ void SettingsHierarchy::onLayerCreated(int layer, Settings *obj) | |
{ | ||
if (layer < 0) | ||
throw BaseException("Invalid settings layer"); | ||
if (layers.size() < layer+1) | ||
layers.resize(layer+1); | ||
if ((int)layers.size() < layer + 1) | ||
layers.resize(layer + 1); | ||
|
||
Settings *&pos = layers[layer]; | ||
if (pos) | ||
|
I would make the parameter 'layer' an unsigned int rather than casting the result of vector::size.
'layer' is used as an index which can't be negative.
This 'fix' makes it worse.