Fix MSVC compiler warnings
This commit is contained in:
parent
0fd334911a
commit
f1bf38004b
|
@ -44,13 +44,13 @@ namespace {
|
||||||
static void makeArrayIndexOutOfBoundsError(std::ostream& oss, const CheckBufferOverrun::ArrayInfo &arrayInfo, const std::vector<MathLib::bigint> &index)
|
static void makeArrayIndexOutOfBoundsError(std::ostream& oss, const CheckBufferOverrun::ArrayInfo &arrayInfo, const std::vector<MathLib::bigint> &index)
|
||||||
{
|
{
|
||||||
oss << "Array '" << arrayInfo.varname();
|
oss << "Array '" << arrayInfo.varname();
|
||||||
for (unsigned int i = 0; i < arrayInfo.num().size(); ++i)
|
for (size_t i = 0; i < arrayInfo.num().size(); ++i)
|
||||||
oss << "[" << arrayInfo.num(i) << "]";
|
oss << "[" << arrayInfo.num(i) << "]";
|
||||||
if (index.size() == 1)
|
if (index.size() == 1)
|
||||||
oss << "' accessed at index " << index[0] << ", which is";
|
oss << "' accessed at index " << index[0] << ", which is";
|
||||||
else {
|
else {
|
||||||
oss << "' index " << arrayInfo.varname();
|
oss << "' index " << arrayInfo.varname();
|
||||||
for (unsigned int i = 0; i < index.size(); ++i)
|
for (size_t i = 0; i < index.size(); ++i)
|
||||||
oss << "[" << index[i] << "]";
|
oss << "[" << index[i] << "]";
|
||||||
}
|
}
|
||||||
oss << " out of bounds.";
|
oss << " out of bounds.";
|
||||||
|
@ -67,19 +67,19 @@ void CheckBufferOverrun::arrayIndexOutOfBoundsError(const Token *tok, const Arra
|
||||||
std::ostringstream errmsg;
|
std::ostringstream errmsg;
|
||||||
|
|
||||||
errmsg << "Array '" << arrayInfo.varname();
|
errmsg << "Array '" << arrayInfo.varname();
|
||||||
for (unsigned int i = 0; i < arrayInfo.num().size(); ++i)
|
for (size_t i = 0; i < arrayInfo.num().size(); ++i)
|
||||||
errmsg << "[" << arrayInfo.num(i) << "]";
|
errmsg << "[" << arrayInfo.num(i) << "]";
|
||||||
if (index.size() == 1)
|
if (index.size() == 1)
|
||||||
errmsg << "' accessed at index " << index[0].intvalue << ", which is out of bounds.";
|
errmsg << "' accessed at index " << index[0].intvalue << ", which is out of bounds.";
|
||||||
else {
|
else {
|
||||||
errmsg << "' index " << arrayInfo.varname();
|
errmsg << "' index " << arrayInfo.varname();
|
||||||
for (unsigned int i = 0; i < index.size(); ++i)
|
for (size_t i = 0; i < index.size(); ++i)
|
||||||
errmsg << "[" << index[i].intvalue << "]";
|
errmsg << "[" << index[i].intvalue << "]";
|
||||||
errmsg << " out of bounds.";
|
errmsg << " out of bounds.";
|
||||||
}
|
}
|
||||||
|
|
||||||
const Token *condition = nullptr;
|
const Token *condition = nullptr;
|
||||||
for (unsigned int i = 0; i < index.size(); ++i) {
|
for (size_t i = 0; i < index.size(); ++i) {
|
||||||
if (condition == nullptr)
|
if (condition == nullptr)
|
||||||
condition = index[i].condition;
|
condition = index[i].condition;
|
||||||
}
|
}
|
||||||
|
@ -324,11 +324,11 @@ void CheckBufferOverrun::checkFunctionParameter(const Token &ftok, unsigned int
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MathLib::bigint arraySize = arrayInfo.element_size();
|
MathLib::bigint arraySize = arrayInfo.element_size();
|
||||||
for (unsigned int i = 0; i < arrayInfo.num().size(); ++i)
|
for (size_t i = 0; i < arrayInfo.num().size(); ++i)
|
||||||
arraySize *= arrayInfo.num(i);
|
arraySize *= arrayInfo.num(i);
|
||||||
|
|
||||||
const Token *charSizeToken = nullptr;
|
const Token *charSizeToken = nullptr;
|
||||||
if (checkMinSizes(*minsizes, &ftok, arraySize, &charSizeToken))
|
if (checkMinSizes(*minsizes, &ftok, (size_t)arraySize, &charSizeToken))
|
||||||
bufferOverrunError(callstack, arrayInfo.varname());
|
bufferOverrunError(callstack, arrayInfo.varname());
|
||||||
if (charSizeToken)
|
if (charSizeToken)
|
||||||
sizeArgumentAsCharError(charSizeToken);
|
sizeArgumentAsCharError(charSizeToken);
|
||||||
|
@ -428,7 +428,7 @@ void CheckBufferOverrun::checkFunctionParameter(const Token &ftok, unsigned int
|
||||||
MathLib::bigint arraysize = arrayInfo.element_size();
|
MathLib::bigint arraysize = arrayInfo.element_size();
|
||||||
if (arraysize == 100) // unknown size
|
if (arraysize == 100) // unknown size
|
||||||
arraysize = 0;
|
arraysize = 0;
|
||||||
for (unsigned int i = 0; i < arrayInfo.num().size(); i++)
|
for (size_t i = 0; i < arrayInfo.num().size(); i++)
|
||||||
arraysize *= arrayInfo.num(i);
|
arraysize *= arrayInfo.num(i);
|
||||||
|
|
||||||
if (Token::Match(tok2, "[,)]") && arraysize > 0 && argsize > arraysize)
|
if (Token::Match(tok2, "[,)]") && arraysize > 0 && argsize > arraysize)
|
||||||
|
|
|
@ -179,7 +179,7 @@ private:
|
||||||
ASSERT_EQUALS(1U, minsizes ? minsizes->size() : 1U);
|
ASSERT_EQUALS(1U, minsizes ? minsizes->size() : 1U);
|
||||||
if (minsizes && minsizes->size() == 1U) {
|
if (minsizes && minsizes->size() == 1U) {
|
||||||
const Library::ArgumentChecks::MinSize &m = minsizes->front();
|
const Library::ArgumentChecks::MinSize &m = minsizes->front();
|
||||||
ASSERT_EQUALS(Library::ArgumentChecks::MinSize::Type::STRLEN, m.type);
|
ASSERT_EQUALS(Library::ArgumentChecks::MinSize::STRLEN, m.type);
|
||||||
ASSERT_EQUALS(2, m.arg);
|
ASSERT_EQUALS(2, m.arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ private:
|
||||||
ASSERT_EQUALS(1U, minsizes ? minsizes->size() : 1U);
|
ASSERT_EQUALS(1U, minsizes ? minsizes->size() : 1U);
|
||||||
if (minsizes && minsizes->size() == 1U) {
|
if (minsizes && minsizes->size() == 1U) {
|
||||||
const Library::ArgumentChecks::MinSize &m = minsizes->front();
|
const Library::ArgumentChecks::MinSize &m = minsizes->front();
|
||||||
ASSERT_EQUALS(Library::ArgumentChecks::MinSize::Type::ARGVALUE, m.type);
|
ASSERT_EQUALS(Library::ArgumentChecks::MinSize::ARGVALUE, m.type);
|
||||||
ASSERT_EQUALS(3, m.arg);
|
ASSERT_EQUALS(3, m.arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue