linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masaharu Noguchi <nogunix@gmail.com>
To: Jeff Layton <jlayton@kernel.org>, Chuck Lever <chuck.lever@oracle.com>
Cc: Jesper Juhl <jesperjuhl76@gmail.com>,
	David Laight <david.laight.linux@gmail.com>,
	Alexander Aring <alex.aring@gmail.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Masaharu Noguchi <nogunix@gmail.com>
Subject: [PATCH v2 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions
Date: Mon, 10 Nov 2025 23:42:32 +0900	[thread overview]
Message-ID: <20251110144232.3765169-3-nogunix@gmail.com> (raw)
In-Reply-To: <20251110144232.3765169-1-nogunix@gmail.com>

Users building the sample after including libc headers such as stdio.h
may inherit libc's AT_RENAME_* macros before <linux/fcntl.h> is pulled
in.  When that happens, the sample ends up with conflicting definitions
or the libc values leak into the rest of the build.

Drop any existing AT_RENAME_* macros before including the uapi header so
that the sample always uses the kernel values and does not trip -Werror
redefinition checks.

Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
---
 samples/vfs/test-statx.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c
index 49c7a46cee07..0123ab4efe0a 100644
--- a/samples/vfs/test-statx.c
+++ b/samples/vfs/test-statx.c
@@ -20,7 +20,16 @@
 #include <sys/syscall.h>
 #include <sys/types.h>
 #include <linux/stat.h>
+
+/* Undefine AT_RENAME_* macros that may have been set by libc headers
+ * (e.g. stdio.h) to avoid redefinition conflicts with uapi fcntl.h.
+ */
+#undef AT_RENAME_NOREPLACE
+#undef AT_RENAME_EXCHANGE
+#undef AT_RENAME_WHITEOUT
+
 #include <linux/fcntl.h>
+
 #define statx foo
 #define statx_timestamp foo_timestamp
 struct statx;
-- 
2.51.1


      parent reply	other threads:[~2025-11-10 14:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10 14:42 [PATCH v2 0/2] uapi/samples: guard renameat2 flag macros Masaharu Noguchi
2025-11-10 14:42 ` [PATCH v2 1/2] uapi: fcntl: guard AT_RENAME_* aliases Masaharu Noguchi
2025-11-10 23:11   ` David Laight
2025-11-10 14:42 ` Masaharu Noguchi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251110144232.3765169-3-nogunix@gmail.com \
    --to=nogunix@gmail.com \
    --cc=alex.aring@gmail.com \
    --cc=chuck.lever@oracle.com \
    --cc=david.laight.linux@gmail.com \
    --cc=jesperjuhl76@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).