mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 05:05:19 -05:00
build: Fix cppcheck issues
This commit is contained in:
@@ -37,7 +37,7 @@ namespace hex::plugin::builtin {
|
||||
m_unit = Unit::Unitless;
|
||||
} else {
|
||||
std::tie(m_unit, m_multiplier) = parseUnit(value.substr(index));
|
||||
value = value.substr(0, index);
|
||||
value.resize(index);
|
||||
}
|
||||
} else {
|
||||
m_unit = Unit::Unitless;
|
||||
|
||||
@@ -105,9 +105,8 @@ namespace hex::plugin::builtin {
|
||||
if (buffer.size() < Size)
|
||||
return { };
|
||||
|
||||
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? hex::format("0x{{0:0{}X}}", Size * 2) : hex::format("0o{{0:0{}o}}", Size * 3));
|
||||
|
||||
return hex::format(format, bufferToInteger<T, Size>(buffer, endian));
|
||||
const auto formatString = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? hex::format("0x{{0:0{}X}}", Size * 2) : hex::format("0o{{0:0{}o}}", Size * 3));
|
||||
return hex::format(formatString, bufferToInteger<T, Size>(buffer, endian));
|
||||
}
|
||||
|
||||
template<std::integral T, size_t Size = sizeof(T)>
|
||||
@@ -371,7 +370,7 @@ namespace hex::plugin::builtin {
|
||||
},
|
||||
[](const std::string &value, std::endian endian) -> std::vector<u8> {
|
||||
std::vector<u8> bytes;
|
||||
auto wideString = wolv::util::utf8ToWstring(value.c_str());
|
||||
auto wideString = wolv::util::utf8ToWstring(value);
|
||||
if (!wideString.has_value())
|
||||
return bytes;
|
||||
|
||||
@@ -733,7 +732,7 @@ namespace hex::plugin::builtin {
|
||||
} else {
|
||||
value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", *time);
|
||||
}
|
||||
} catch (fmt::format_error &e) {
|
||||
} catch (const fmt::format_error &e) {
|
||||
value = "Invalid";
|
||||
}
|
||||
|
||||
|
||||
@@ -199,9 +199,9 @@ namespace hex::plugin::builtin {
|
||||
|
||||
std::shared_ptr<pl::ptrn::Pattern> jsonToPattern(pl::core::Evaluator *evaluator, auto function) {
|
||||
auto object = std::make_shared<pl::ptrn::PatternStruct>(evaluator, 0, 0, 0);
|
||||
std::vector<std::shared_ptr<pl::ptrn::Pattern>> patterns;
|
||||
|
||||
try {
|
||||
std::vector<std::shared_ptr<pl::ptrn::Pattern>> patterns;
|
||||
jsonToPattern(evaluator, function(), patterns);
|
||||
object->setEntries(patterns);
|
||||
|
||||
@@ -280,7 +280,6 @@ namespace hex::plugin::builtin {
|
||||
auto bytes = params[0].toBytes();
|
||||
auto encodingDefinition = params[1].toString();
|
||||
|
||||
std::string value;
|
||||
EncodingFile encodingFile(EncodingFile::Type::Thingy, encodingDefinition);
|
||||
|
||||
auto pattern = std::make_shared<PatternEncodedString>(evaluator, evaluator->getReadOffset(), bytes.size(), 0);
|
||||
|
||||
@@ -99,6 +99,7 @@ namespace hex::plugin::builtin {
|
||||
socket.writeString(packet);
|
||||
|
||||
auto receivedPacket = socket.readString(6);
|
||||
std::ignore = receivedPacket;
|
||||
}
|
||||
|
||||
bool enableNoAckMode(const wolv::net::SocketClient &socket) {
|
||||
@@ -157,7 +158,7 @@ namespace hex::plugin::builtin {
|
||||
if (size <= CacheLineSize) {
|
||||
std::scoped_lock lock(m_cacheLock);
|
||||
|
||||
const auto &cacheLine = std::find_if(m_cache.begin(), m_cache.end(), [&](auto &line) {
|
||||
const auto &cacheLine = std::ranges::find_if(m_cache, [&](const auto &line) {
|
||||
return line.address == alignedOffset;
|
||||
});
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace hex::plugin::builtin {
|
||||
if (!data.empty() && checksum != 0x00)
|
||||
throw std::runtime_error("Checksum mismatch");
|
||||
|
||||
while (std::isspace(string[offset]) && offset < string.length())
|
||||
while (offset < string.length() && std::isspace(string[offset]))
|
||||
offset++;
|
||||
|
||||
// Construct region
|
||||
@@ -145,7 +145,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
while (std::isspace(string[offset]) && offset < string.length())
|
||||
while (offset < string.length() && std::isspace(string[offset]))
|
||||
offset++;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,21 +57,21 @@ namespace hex::plugin::builtin {
|
||||
return value;
|
||||
};
|
||||
|
||||
enum class RecordType {
|
||||
Header = 0x00,
|
||||
Data16 = 0x01,
|
||||
Data24 = 0x02,
|
||||
Data32 = 0x03,
|
||||
Reserved = 0x04,
|
||||
Count16 = 0x05,
|
||||
Count24 = 0x06,
|
||||
StartAddress32 = 0x07,
|
||||
StartAddress24 = 0x08,
|
||||
StartAddress16 = 0x09,
|
||||
} recordType;
|
||||
|
||||
bool endOfFile = false;
|
||||
try {
|
||||
enum class RecordType {
|
||||
Header = 0x00,
|
||||
Data16 = 0x01,
|
||||
Data24 = 0x02,
|
||||
Data32 = 0x03,
|
||||
Reserved = 0x04,
|
||||
Count16 = 0x05,
|
||||
Count24 = 0x06,
|
||||
StartAddress32 = 0x07,
|
||||
StartAddress24 = 0x08,
|
||||
StartAddress16 = 0x09,
|
||||
} recordType;
|
||||
bool endOfFile = false;
|
||||
|
||||
while (offset < string.length()) {
|
||||
// Parse record start
|
||||
if (c() != 'S')
|
||||
@@ -159,7 +159,7 @@ namespace hex::plugin::builtin {
|
||||
break;
|
||||
}
|
||||
|
||||
while (std::isspace(string[offset]) && offset < string.length())
|
||||
while (offset < string.length() && std::isspace(string[offset]))
|
||||
offset++;
|
||||
}
|
||||
} catch (const std::runtime_error &e) {
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void drawColorPicker() {
|
||||
static std::array<float, 4> pickedColor = { 0 };
|
||||
static std::string rgba8;
|
||||
|
||||
struct BitValue {
|
||||
int bits;
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
void drawEuclidianAlgorithm() {
|
||||
static u64 a, b;
|
||||
|
||||
static i64 gcdResult = 0;
|
||||
static i64 lcmResult = 0;
|
||||
static i64 p = 0, q = 0;
|
||||
@@ -37,6 +35,8 @@ namespace hex::plugin::builtin {
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGuiExt::BeginBox()) {
|
||||
static u64 a = 0, b = 0;
|
||||
|
||||
bool hasChanged = false;
|
||||
hasChanged = ImGui::InputScalar("A", ImGuiDataType_U64, &a) || hasChanged;
|
||||
hasChanged = ImGui::InputScalar("B", ImGuiDataType_U64, &b) || hasChanged;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (ImGui::BeginListBox("##files", { -FLT_MIN, 10 * ImGui::GetTextLineHeightWithSpacing() })) {
|
||||
u32 index = 0;
|
||||
for (auto &file : files) {
|
||||
for (const auto &file : files) {
|
||||
if (ImGui::Selectable(wolv::util::toUTF8String(file).c_str(), index == selectedIndex))
|
||||
selectedIndex = index;
|
||||
index++;
|
||||
@@ -41,7 +41,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::BeginDisabled(selectedIndex <= 0);
|
||||
ImGui::BeginDisabled(selectedIndex == 0);
|
||||
{
|
||||
if (ImGui::ArrowButton("move_up", ImGuiDir_Up)) {
|
||||
std::iter_swap(files.begin() + selectedIndex, files.begin() + selectedIndex - 1);
|
||||
|
||||
@@ -74,9 +74,9 @@ namespace hex::plugin::builtin {
|
||||
i64 precision;
|
||||
} ieee754 = {};
|
||||
|
||||
std::string specialNumbers[] = {
|
||||
"inf" , "Inf", "INF" , "nan" , "Nan" , "NAN",
|
||||
"qnan","Qnan", "QNAN", "snan", "Snan", "SNAN"
|
||||
constexpr static std::array SpecialNumbers = {
|
||||
"inf" , "Inf", "INF" , "nan" , "Nan" , "NAN",
|
||||
"qnan","Qnan", "QNAN", "snan", "Snan", "SNAN"
|
||||
};
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
};
|
||||
|
||||
const static auto FloatToBits = [&specialNumbers](IEEE754 &ieee754, std::string decimalFloatingPointNumberString, int totalBitCount) {
|
||||
const static auto FloatToBits = [](IEEE754 &ieee754, std::string decimalFloatingPointNumberString, int totalBitCount) {
|
||||
|
||||
// Always obtain sign first.
|
||||
if (decimalFloatingPointNumberString[0] == '-') {
|
||||
@@ -362,7 +362,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
// Detect and use special numbers.
|
||||
for (u32 i = 0; i < 12; i++) {
|
||||
if (decimalFloatingPointNumberString == specialNumbers[i]) {
|
||||
if (decimalFloatingPointNumberString == SpecialNumbers[i]) {
|
||||
inputType = InputType(i/3);
|
||||
matchFound = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user