1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +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:
Lenny Maiorani 2020-12-20 16:09:48 -07:00 committed by GitHub
parent 4421d98e30
commit 765936ebae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
103 changed files with 219 additions and 362 deletions

View file

@ -337,7 +337,6 @@ JS_DEFINE_NATIVE_GETTER(WindowObject::document_getter)
JS_DEFINE_NATIVE_SETTER(WindowObject::document_setter)
{
// FIXME: Figure out what we should do here. Just ignore attempts to set window.document for now.
UNUSED_PARAM(value);
}
JS_DEFINE_NATIVE_GETTER(WindowObject::performance_getter)

View file

@ -48,10 +48,9 @@ namespace Web::DOM {
// FIXME: This shouldn't be here, as retargeting is not only used by the event dispatcher.
// When moving this function, it needs to be generalized. https://dom.spec.whatwg.org/#retarget
static EventTarget* retarget(EventTarget* left, EventTarget* right)
static EventTarget* retarget(EventTarget* left, [[maybe_unused]] EventTarget* right)
{
// FIXME
UNUSED_PARAM(right);
for (;;) {
if (!is<Node>(left))
return left;
@ -110,7 +109,7 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<EventTarget::EventListen
auto* this_value = Bindings::wrap(global, *event.current_target());
auto* wrapped_event = Bindings::wrap(global, event);
auto& vm = global.vm();
(void)vm.call(listener.listener->function(), this_value, wrapped_event);
[[maybe_unused]] auto rc = vm.call(listener.listener->function(), this_value, wrapped_event);
if (vm.exception()) {
vm.clear_exception();
// FIXME: Set legacyOutputDidListenersThrowFlag if given. (Only used by IndexedDB currently)

View file

@ -98,7 +98,7 @@ void Window::timer_did_fire(Badge<Timer>, Timer& timer)
m_timers.remove(timer.id());
}
(void)vm.call(timer.callback(), wrapper());
[[maybe_unused]] auto rc = vm.call(timer.callback(), wrapper());
if (vm.exception())
vm.clear_exception();
}
@ -132,7 +132,7 @@ i32 Window::request_animation_frame(JS::Function& callback)
auto& function = const_cast<JS::Function&>(static_cast<const JS::Function&>(*handle.cell()));
auto& vm = function.vm();
fake_timestamp += 10;
(void)vm.call(function, {}, JS::Value(fake_timestamp));
[[maybe_unused]] auto rc = vm.call(function, {}, JS::Value(fake_timestamp));
if (vm.exception())
vm.clear_exception();
GUI::DisplayLink::unregister_callback(link_id);

View file

@ -301,9 +301,8 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
return true;
}
void EventHandler::dump_selection(const char* event_name) const
void EventHandler::dump_selection([[maybe_unused]] const char* event_name) const
{
UNUSED_PARAM(event_name);
#ifdef SELECTION_DEBUG
dbg() << event_name << " selection start: "
<< layout_root()->selection().start().layout_node << ":" << layout_root()->selection().start().index_in_node << ", end: "

View file

@ -359,7 +359,7 @@ inline void TreeNode<T>::append_child(NonnullRefPtr<T> node, bool notify)
m_first_child = m_last_child;
if (notify)
node->inserted_into(static_cast<T&>(*this));
(void)node.leak_ref();
[[maybe_unused]] auto& rc = node.leak_ref();
if (notify)
static_cast<T*>(this)->children_changed();
@ -394,7 +394,7 @@ inline void TreeNode<T>::insert_before(NonnullRefPtr<T> node, RefPtr<T> child, b
node->m_parent = static_cast<T*>(this);
if (notify)
node->inserted_into(static_cast<T&>(*this));
(void)node.leak_ref();
[[maybe_unused]] auto& rc = node.leak_ref();
if (notify)
static_cast<T*>(this)->children_changed();
@ -416,7 +416,7 @@ inline void TreeNode<T>::prepend_child(NonnullRefPtr<T> node)
if (!m_last_child)
m_last_child = m_first_child;
node->inserted_into(static_cast<T&>(*this));
(void)node.leak_ref();
[[maybe_unused]] auto& rc = node.leak_ref();
static_cast<T*>(this)->children_changed();
}