[PATCH 2/3] NFS: flexfilelayout: Mark err as __maybe_unused in ff_layout_io_track_ds_error
From: Peng Fan (OSS)
Date: Fri Feb 27 2026 - 03:19:16 EST
From: Peng Fan <peng.fan@xxxxxxx>
Fix the following compiler warning when building with W=1:
flexfilelayout.c: In function 'ff_layout_io_track_ds_error':
flexfilelayout.c:1503:6:
error: variable 'err' set but not used [-Werror=unused-but-set-variable]
1503 | int err;
| ^~~
Variable 'err' is assigned the return value of ff_layout_track_ds_error()
but is only used in the dprintk() debug statement at the end of the
function. When debug output is disabled, the variable appears unused to
the compiler.
Mark it as __maybe_unused to indicate this is intentional.
Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
---
fs/nfs/flexfilelayout/flexfilelayout.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index cd175204807600ff4e33ff769e03ef7ac700a6dc..1d8099337652a1cdbcaf58d394a6e981e8e7e413 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1500,7 +1500,7 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,
{
struct nfs4_ff_layout_mirror *mirror;
u32 status = *op_status;
- int err;
+ int err __maybe_unused;
if (status == 0) {
switch (error) {
--
2.37.1