commonlib: Substitude macro "__unused" in compiler.h

Since there are many identifiers whose name contain "__unused" in
headers of musl libc, introducing a macro which expands "__unused" to
the source of a util may have disastrous effect during its compiling
under a musl-based platform.

However, it is hard to detect musl at build time as musl is notorious
for having explicitly been refusing to add a macro like "__MUSL__" to
announce its own presence.

Using __always_unused and __maybe_unused for everything may be a good
idea. This is how it works in the Linux kernel, so that would at least
make us match some other standard rather than doing our own thing
(especially since the other compiler.h shorthand macros are also
inspired by Linux).

Signed-off-by: Bill XIE <persmule@hardenedlinux.org>
Change-Id: I547ae3371d7568f5aed732ceefe0130a339716a9
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65717
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Bill XIE
2022-07-08 16:53:21 +08:00
committed by Felix Held
parent f7ba881f98
commit ac136250b2
11 changed files with 35 additions and 17 deletions

View File

@@ -127,7 +127,7 @@ static const char *crb_tpm_acpi_name(const struct device *dev)
return "TPM";
}
static struct device_operations __unused crb_ops = {
static struct device_operations __maybe_unused crb_ops = {
.read_resources = noop_read_resources,
.set_resources = noop_set_resources,
#if CONFIG(HAVE_ACPI_TABLES)

View File

@@ -210,7 +210,7 @@ static int lookup_response_length(int response_type)
static int response_resolve(int response_type, uint8_t *response,
uint32_t *out_register)
{
__unused static const char * const sd_err[] = {
__maybe_unused static const char * const sd_err[] = {
"Card is locked",
"wp erase skip | lock/unlok cmd failed",
"error",