Skip to content

Commit d9be3c3

Browse files
Update ctu.cpp
1 parent e1a6600 commit d9be3c3

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lib/ctu.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,20 @@ static bool findPath(const std::string &callId,
559559
return false;
560560
}
561561

562+
static std::string getInvalidValueString(CTU::FileInfo::InvalidValueType invalidValue)
563+
{
564+
using InvalidValueType = CTU::FileInfo::InvalidValueType;
565+
switch (invalidValue) {
566+
case InvalidValueType::null:
567+
return "null";
568+
case InvalidValueType::uninit:
569+
return "uninitialized";
570+
case InvalidValueType::bufferOverflow:
571+
return "accessed out of bounds";
572+
}
573+
cppcheck::unreachable();
574+
}
575+
562576
std::list<ErrorMessage::FileLocation> CTU::FileInfo::getErrorPath(InvalidValueType invalidValue,
563577
const CTU::FileInfo::UnsafeUsage &unsafeUsage,
564578
const std::map<std::string, std::list<const CTU::FileInfo::CallBase *>> &callsMap,
@@ -581,7 +595,7 @@ std::list<ErrorMessage::FileLocation> CTU::FileInfo::getErrorPath(InvalidValueTy
581595

582596
std::list<ErrorMessage::FileLocation> locationList;
583597

584-
const std::string value1 = (invalidValue == InvalidValueType::null) ? "null" : "uninitialized";
598+
const std::string value1 = getInvalidValueString(invalidValue);
585599

586600
for (int index = 9; index >= 0; index--) {
587601
if (!path[index])

0 commit comments

Comments
 (0)