1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +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

@ -188,8 +188,7 @@ static void allocate_tls()
total_tls_size += data.value->tls_size();
}
if (total_tls_size) {
void* tls_address = allocate_tls(total_tls_size);
(void)tls_address;
[[maybe_unused]] void* tls_address = allocate_tls(total_tls_size);
VERBOSE("from userspace, tls_address: %p", tls_address);
}
g_total_tls_size = total_tls_size;
@ -211,7 +210,7 @@ static void initialize_libc()
res = global_symbol_lookup("__libc_init");
ASSERT(res.found);
typedef void libc_init_func(void);
typedef void libc_init_func();
((libc_init_func*)res.address)();
}
@ -262,8 +261,7 @@ static FlatPtr loader_main(auxv_t* auxvp)
map_dependencies(main_program_name);
VERBOSE("loaded all dependencies");
for (auto& lib : g_loaders) {
(void)lib;
for ([[maybe_unused]] auto& lib : g_loaders) {
VERBOSE("%s - tls size: $u, tls offset: %u", lib.key.characters(), lib.value->tls_size(), lib.value->tls_offset());
}
@ -301,8 +299,7 @@ void _start(int argc, char** argv, char** envp)
FlatPtr entry = loader_main(auxvp);
VERBOSE("Loaded libs:\n");
for (auto& obj : g_loaded_objects) {
(void)obj;
for ([[maybe_unused]] auto& obj : g_loaded_objects) {
VERBOSE("%s: %p\n", obj.key.characters(), obj.value->base_address().as_ptr());
}