fix: Random build errors with GCC 12.1.0

This commit is contained in:
WerWolv
2022-05-17 20:46:42 +02:00
parent 5f17d7aa75
commit c4b7d89713
9 changed files with 48 additions and 42 deletions

View File

@@ -92,14 +92,16 @@ namespace hex::plugin::builtin {
ImGui::TextUnformatted(binary.c_str());
return binary;
};
}, [](std::string value, std::endian endian) -> std::vector<u8> {
}, [](const std::string &value, std::endian endian) -> std::vector<u8> {
hex::unused(endian);
if (value.starts_with("0b"))
value = value.substr(2);
std::string copy = value;
if (copy.starts_with("0b"))
copy = copy.substr(2);
if (value.size() > 8) return { };
u8 byte = 0x00;
for (char c : value) {
for (char c : copy) {
byte <<= 1;
if (c == '1')

View File

@@ -226,12 +226,10 @@ namespace hex::plugin::builtin::prv {
}
std::string GDBProvider::getName() const {
std::string address, port;
std::string address = "-";
std::string port = "-";
if (!this->isConnected()) {
address = "-";
port = "-";
} else {
if (this->isConnected()) {
address = this->m_ipAddress;
port = std::to_string(this->m_port);
}

View File

@@ -425,19 +425,18 @@ namespace hex::plugin::builtin {
ImGui::NewLine();
if (evaluate) {
std::optional<long double> result;
try {
result = mathEvaluator.evaluate(mathInput);
auto result = mathEvaluator.evaluate(mathInput);
if (result.has_value()) {
mathHistory.push_back(result.value());
mathInput.clear();
lastMathError.clear();
}
} catch (std::invalid_argument &e) {
lastMathError = e.what();
}
if (result.has_value()) {
mathHistory.push_back(result.value());
mathInput.clear();
lastMathError.clear();
}
}
}

View File

@@ -7,7 +7,7 @@
namespace hex::plugin::builtin {
ViewCommandPalette::ViewCommandPalette() : View("hex.builtin.view.command_palette.name") {
this->m_commandBuffer.resize(1024, 0x00);
this->m_commandBuffer = std::vector<char>(1024, 0x00);
ShortcutManager::addGlobalShortcut(CTRL + SHIFT + Keys::P, [this] {
EventManager::post<RequestOpenPopup>("hex.builtin.view.command_palette.name"_lang);

View File

@@ -366,7 +366,7 @@ namespace hex::plugin::builtin {
if (ImNodes::IsLinkCreated(&from, &to)) {
do {
dp::Attribute *fromAttr, *toAttr;
dp::Attribute *fromAttr = nullptr, *toAttr = nullptr;
for (auto &node : this->m_nodes) {
for (auto &attribute : node->getAttributes()) {
if (attribute.getId() == static_cast<u32>(from))
@@ -535,7 +535,7 @@ namespace hex::plugin::builtin {
newLink.setID(linkId);
this->m_links.push_back(newLink);
dp::Attribute *fromAttr, *toAttr;
dp::Attribute *fromAttr = nullptr, *toAttr = nullptr;
for (auto &node : this->m_nodes) {
for (auto &attribute : node->getAttributes()) {
if (attribute.getId() == newLink.getFromId())

View File

@@ -26,8 +26,8 @@ namespace hex::plugin::builtin {
ViewHexEditor::ViewHexEditor() : View("hex.builtin.view.hex_editor.name"_lang) {
this->m_searchStringBuffer.resize(0xFFF, 0x00);
this->m_searchHexBuffer.resize(0xFFF, 0x00);
this->m_searchStringBuffer = std::vector<char>(0xFFF, 0x00);
this->m_searchHexBuffer = std::vector<char>(0xFFF, 0x00);
ContentRegistry::FileHandler::add({ ".hexproj" }, [](const auto &path) {
return ProjectFile::load(path);