diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2023-05-11 11:04:30 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-15 07:00:29 +0200 |
commit | fc003cd2481e654154a02f5772ecac19ed102294 (patch) | |
tree | 98f438090c4b106a83677073467a7b40396cc01a | |
parent | 2123fdd6783a756751d72bba394d106ac15c842e (diff) | |
download | serenity-fc003cd2481e654154a02f5772ecac19ed102294.zip |
Userland: Silence or resolve new GCC 13 warnings
GCC 13 produces the following true positive warnings:
- `-Wredundant-move` when trying to move `result->tooltip()`, which
is a const reference in `Assistant/main.cpp`
- `-Wuse-after-free` when freeing an environment variable before
removing it from `s_malloced_environment_variables`
- `-Wdangling-pointer` when storing an AST node's `this` pointer to the
interpreter's node stack in LibJS. This is not actually an issue, as
it is popped when the scope ends, but GCC has no way of telling this.
-rw-r--r-- | Userland/Applications/Assistant/main.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibC/stdlib.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/AST.cpp | 4 |
3 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp index 752eff40de..483e45464c 100644 --- a/Userland/Applications/Assistant/main.cpp +++ b/Userland/Applications/Assistant/main.cpp @@ -251,7 +251,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto& match = results_container.add<Assistant::ResultRow>(); match.set_icon(result->bitmap()); match.set_text(String::from_deprecated_string(result->title()).release_value_but_fixme_should_propagate_errors()); - match.set_tooltip(move(result->tooltip())); + match.set_tooltip(result->tooltip()); match.on_click = [&result](auto) { result->activate(); GUI::Application::the()->quit(); diff --git a/Userland/Libraries/LibC/stdlib.cpp b/Userland/Libraries/LibC/stdlib.cpp index 687de3a7a3..8e006129e0 100644 --- a/Userland/Libraries/LibC/stdlib.cpp +++ b/Userland/Libraries/LibC/stdlib.cpp @@ -399,8 +399,8 @@ static void free_environment_variable_if_needed(char const* var) { if (!s_malloced_environment_variables.contains((FlatPtr)var)) return; - free(const_cast<char*>(var)); s_malloced_environment_variables.remove((FlatPtr)var); + free(const_cast<char*>(var)); } char* getenv(char const* name) diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 4a5c4f5626..09e8663230 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -48,7 +48,11 @@ public: , m_chain_node { nullptr, node } { m_interpreter.vm().running_execution_context().current_node = &node; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdangling-pointer" + // The node pointer is popped from the interpreter in the destructor. m_interpreter.push_ast_node(m_chain_node); +#pragma GCC diagnostic push } ~InterpreterNodeScope() |