1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:17:35 +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

@ -74,7 +74,7 @@ int main(int argc, char** argv, char** envp)
outln("Global lib variable is {}", *ptr_global);
// Test getting a method from the library and calling it
void (*lib_func)(void) = (void (*)(void))dlsym(handle, "global_lib_function");
void (*lib_func)() = (void (*)())dlsym(handle, "global_lib_function");
outln("Found global lib function address: {}", lib_func);

View file

@ -39,12 +39,8 @@
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char** argv, char** env)
int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv, [[maybe_unused]] char** env)
{
(void)argc;
(void)argv;
(void)env;
printf("Well Hello Friends!\n");
printf("trying to open /etc/fstab for writing..\n");
int rc = open("/etc/fstab", O_RDWR);

View file

@ -146,8 +146,7 @@ int main(int argc, char** argv)
auto& radio1 = radio_button_container.add<GUI::RadioButton>("RadioButton 1");
radio1.set_checked(true);
auto& radio2 = radio_button_container.add<GUI::RadioButton>("RadioButton 2");
(void)radio2;
[[maybe_unused]] auto& radio2 = radio_button_container.add<GUI::RadioButton>("RadioButton 2");
auto& radio3 = radio_button_container.add<GUI::RadioButton>("RadioButton 3");
radio3.set_enabled(false);
@ -186,13 +185,11 @@ int main(int argc, char** argv)
auto& checkbox2 = checkbox_container.add<GUI::CheckBox>("CheckBox 2");
checkbox2.set_enabled(false);
auto& label1 = label_container.add<GUI::Label>("Label 1");
(void)label1;
[[maybe_unused]] auto& label1 = label_container.add<GUI::Label>("Label 1");
auto& label2 = label_container.add<GUI::Label>("Label 2");
label2.set_enabled(false);
auto& spinbox1 = spin_container.add<GUI::SpinBox>();
(void)spinbox1;
[[maybe_unused]] auto& spinbox1 = spin_container.add<GUI::SpinBox>();
auto& spinbox2 = spin_container.add<GUI::SpinBox>();
spinbox2.set_enabled(false);
@ -213,8 +210,7 @@ int main(int argc, char** argv)
auto& button2 = button_vert1_container.add<GUI::Button>("Button 2");
button2.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/kill.png"));
button2.set_enabled(false);
auto& button3 = button_vert2_container.add<GUI::Button>("\xF0\x9F\x98\x88 Button 3");
(void)button3;
[[maybe_unused]] auto& button3 = button_vert2_container.add<GUI::Button>("\xF0\x9F\x98\x88 Button 3");
auto& button4 = button_vert2_container.add<GUI::Button>("\xF0\x9F\x8D\x86 Button 4");
button4.set_enabled(false);
@ -334,8 +330,7 @@ int main(int argc, char** argv)
horizontal_slider_container2.set_layout<GUI::HorizontalBoxLayout>();
horizontal_slider_container2.layout()->set_margins({ 4, 4, 4, 4 });
auto& slider1 = horizontal_slider_container.add<GUI::HorizontalSlider>();
(void)slider1;
[[maybe_unused]] auto& slider1 = horizontal_slider_container.add<GUI::HorizontalSlider>();
auto& slider2 = horizontal_slider_container.add<GUI::HorizontalSlider>();
slider2.set_enabled(false);
slider2.set_value(50);