Refactoring; replace for loop with std::find_if
This commit is contained in:
parent
aaf1af6736
commit
f503386666
|
@ -63,11 +63,9 @@ static const CWE CWE_BUFFER_OVERRUN(788U); // Access of Memory Location After
|
||||||
|
|
||||||
static const ValueFlow::Value *getBufferSizeValue(const Token *tok)
|
static const ValueFlow::Value *getBufferSizeValue(const Token *tok)
|
||||||
{
|
{
|
||||||
for (const ValueFlow::Value &value : tok->values()) {
|
const std::list<ValueFlow::Value> &tokenValues = tok->values();
|
||||||
if (value.isBufferSizeValue())
|
const auto it = std::find_if(tokenValues.begin(), tokenValues.end(), std::mem_fn(&ValueFlow::Value::isBufferSizeValue));
|
||||||
return &value;
|
return it == tokenValues.end() ? nullptr : &*it;
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t getMinFormatStringOutputLength(const std::vector<const Token*> ¶meters, unsigned int formatStringArgNr)
|
static size_t getMinFormatStringOutputLength(const std::vector<const Token*> ¶meters, unsigned int formatStringArgNr)
|
||||||
|
|
Loading…
Reference in New Issue