The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=84a95741805d84f0074a34d61b93ccf86f422cf3
commit 84a95741805d84f0074a34d61b93ccf86f422cf3 Author: Hans Rosenfeld <[email protected]> AuthorDate: 2026-04-16 18:22:44 +0000 Commit: Ed Maste <[email protected]> CommitDate: 2026-05-06 19:51:46 +0000 sys/cdefs.h: Introduce __maybe_unused attribute The __maybe_unused attribute should be used for variables which may or may not be used, such as when their only use is in an assertion. This attribute is functionally identical to __unused, suppressing compiler warnings for particular variable if it remains unused. Reviewed by: Minsoo Choo <[email protected]>, imp Differential Revision: https://reviews.freebsd.org/D56517 --- share/man/man9/cdefs.9 | 6 ++++-- sys/compat/linuxkpi/common/include/linux/compiler_attributes.h | 1 - sys/sys/cdefs.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/share/man/man9/cdefs.9 b/share/man/man9/cdefs.9 index cc56e34d070a..2bda50c3f875 100644 --- a/share/man/man9/cdefs.9 +++ b/share/man/man9/cdefs.9 @@ -3,7 +3,7 @@ .\" .\" SPDX-License-Identifier: BSD-2-Clause .\" -.Dd May 9, 2025 +.Dd May 6, 2026 .Dt CDEFS 9 .Os .Sh NAME @@ -85,7 +85,9 @@ linkage. .It Sy __weak_symbol Ta Declare the symbol to be a weak symbol .It Sy __dead2 Ta Function will not return .It Sy __pure2 Ta Function has no side effects -.It Sy __unused Ta To Variable may be unused (usually arguments), so do not +.It Sy __unused Ta Variable may be unused (usually arguments), so do not +warn about it +.It Sy __maybe_unused Ta Variable may be unused (usually arguments), so do not warn about it .It Sy __used Ta Function really is used, so emit it even if it appears unused. .It Sy __deprecated Ta Function interface has been deprecated, and clients diff --git a/sys/compat/linuxkpi/common/include/linux/compiler_attributes.h b/sys/compat/linuxkpi/common/include/linux/compiler_attributes.h index 42908bb6c2b5..159c833802c5 100644 --- a/sys/compat/linuxkpi/common/include/linux/compiler_attributes.h +++ b/sys/compat/linuxkpi/common/include/linux/compiler_attributes.h @@ -39,7 +39,6 @@ #define noinline_for_stack __noinline -#define __maybe_unused __unused #define __always_unused __unused #define __must_check __result_use_check diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 132d4809b0ed..a08c50c8439a 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -152,6 +152,7 @@ #define __weak_symbol __attribute__((__weak__)) #define __dead2 __attribute__((__noreturn__)) #define __pure2 __attribute__((__const__)) +#define __maybe_unused __attribute__((__unused__)) #define __unused __attribute__((__unused__)) #define __used __attribute__((__used__)) #define __deprecated __attribute__((__deprecated__))
