mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:07:36 +00:00
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem: - `(void)` simply casts the expression to void. This is understood to indicate that it is ignored, but this is really a compiler trick to get the compiler to not generate a warning. Solution: - Use the `[[maybe_unused]]` attribute to indicate the value is unused. Note: - Functions taking a `(void)` argument list have also been changed to `()` because this is not needed and shows up in the same grep command.
This commit is contained in:
parent
4421d98e30
commit
765936ebae
103 changed files with 219 additions and 362 deletions
|
@ -156,11 +156,8 @@ void DownloadWidget::did_progress(Optional<u32> total_size, u32 downloaded_size)
|
|||
}
|
||||
}
|
||||
|
||||
void DownloadWidget::did_finish(bool success, ReadonlyBytes payload, RefPtr<SharedBuffer> payload_storage, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers)
|
||||
void DownloadWidget::did_finish(bool success, [[maybe_unused]] ReadonlyBytes payload, [[maybe_unused]] RefPtr<SharedBuffer> payload_storage, [[maybe_unused]] const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers)
|
||||
{
|
||||
(void)payload;
|
||||
(void)payload_storage;
|
||||
(void)response_headers;
|
||||
dbg() << "did_finish, success=" << success;
|
||||
|
||||
m_close_button->set_enabled(true);
|
||||
|
|
|
@ -82,7 +82,7 @@ static void start_download(const URL& url)
|
|||
window->set_resizable(false);
|
||||
window->set_main_widget<DownloadWidget>(url);
|
||||
window->show();
|
||||
(void)window.leak_ref();
|
||||
[[maybe_unused]] auto& unused = window.leak_ref();
|
||||
}
|
||||
|
||||
Tab::Tab(Type type)
|
||||
|
@ -308,7 +308,7 @@ Tab::Tab(Type type)
|
|||
window->set_title(url);
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-text.png"));
|
||||
window->show();
|
||||
(void)window.leak_ref();
|
||||
[[maybe_unused]] auto& unused = window.leak_ref();
|
||||
} else {
|
||||
TODO();
|
||||
}
|
||||
|
|
|
@ -183,13 +183,12 @@ void show_properties(const String& container_dir_path, const String& path, const
|
|||
properties->exec();
|
||||
}
|
||||
|
||||
int run_in_desktop_mode(RefPtr<Core::ConfigFile> config)
|
||||
int run_in_desktop_mode([[maybe_unused]] RefPtr<Core::ConfigFile> config)
|
||||
{
|
||||
static constexpr const char* process_name = "FileManager (Desktop)";
|
||||
set_process_name(process_name, strlen(process_name));
|
||||
pthread_setname_np(pthread_self(), process_name);
|
||||
|
||||
(void)config;
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title("Desktop Manager");
|
||||
window->set_window_type(GUI::WindowType::Desktop);
|
||||
|
@ -198,8 +197,7 @@ int run_in_desktop_mode(RefPtr<Core::ConfigFile> config)
|
|||
auto& desktop_widget = window->set_main_widget<FileManager::DesktopWidget>();
|
||||
desktop_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto& directory_view = desktop_widget.add<DirectoryView>(DirectoryView::Mode::Desktop);
|
||||
(void)directory_view;
|
||||
[[maybe_unused]] auto& directory_view = desktop_widget.add<DirectoryView>(DirectoryView::Mode::Desktop);
|
||||
|
||||
auto copy_action = GUI::CommonActions::make_copy_action(
|
||||
[&](auto&) {
|
||||
|
|
|
@ -773,9 +773,8 @@ void IRCClient::handle_rpl_whoisuser(const Message& msg)
|
|||
auto& nick = msg.arguments[1];
|
||||
auto& username = msg.arguments[2];
|
||||
auto& host = msg.arguments[3];
|
||||
auto& asterisk = msg.arguments[4];
|
||||
[[maybe_unused]] auto& asterisk = msg.arguments[4];
|
||||
auto& realname = msg.arguments[5];
|
||||
(void)asterisk;
|
||||
add_server_message(String::formatted("* {} is {}@{}, real name: {}", nick, username, host, realname));
|
||||
}
|
||||
|
||||
|
|
|
@ -204,9 +204,8 @@ void RollWidget::mousemove_event(GUI::MouseEvent& event)
|
|||
update();
|
||||
}
|
||||
|
||||
void RollWidget::mouseup_event(GUI::MouseEvent& event)
|
||||
void RollWidget::mouseup_event([[maybe_unused]] GUI::MouseEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
m_note_drag_start = {};
|
||||
m_note_drag_location = {};
|
||||
}
|
||||
|
|
|
@ -200,10 +200,7 @@ void QSWidget::mousedown_event(GUI::MouseEvent& event)
|
|||
m_saved_pan_origin = m_pan_origin;
|
||||
}
|
||||
|
||||
void QSWidget::mouseup_event(GUI::MouseEvent& event)
|
||||
{
|
||||
UNUSED_PARAM(event);
|
||||
}
|
||||
void QSWidget::mouseup_event([[maybe_unused]] GUI::MouseEvent& event) { }
|
||||
|
||||
void QSWidget::mousemove_event(GUI::MouseEvent& event)
|
||||
{
|
||||
|
|
|
@ -105,8 +105,7 @@ void MemoryStatsWidget::refresh()
|
|||
ASSERT(json_result.has_value());
|
||||
auto json = json_result.value().as_object();
|
||||
|
||||
unsigned kmalloc_eternal_allocated = json.get("kmalloc_eternal_allocated").to_u32();
|
||||
(void)kmalloc_eternal_allocated;
|
||||
[[maybe_unused]] unsigned kmalloc_eternal_allocated = json.get("kmalloc_eternal_allocated").to_u32();
|
||||
unsigned kmalloc_allocated = json.get("kmalloc_allocated").to_u32();
|
||||
unsigned kmalloc_available = json.get("kmalloc_available").to_u32();
|
||||
unsigned user_physical_allocated = json.get("user_physical_allocated").to_u32();
|
||||
|
|
|
@ -278,8 +278,7 @@ int main(int argc, char** argv)
|
|||
process_context_menu->add_separator();
|
||||
process_context_menu->add_action(profile_action);
|
||||
process_context_menu->add_action(inspect_action);
|
||||
process_table_view.on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
||||
(void)index;
|
||||
process_table_view.on_context_menu_request = [&]([[maybe_unused]] const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
||||
process_context_menu->popup(event.screen_position());
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue