From: Madhur Kumar <madhurkumar004@gmail.com>
To: brauner@kernel.org, jlayton@kernel.org, geert+renesas@glider.be,
arnd@arndb.de
Cc: linux-kernel@vger.kernel.org, Madhur Kumar <madhurkumar004@gmail.com>
Subject: [PATCH] samples/vfs: Undefine conflicting AT_RENAME_* macros in test-statx
Date: Sun, 5 Oct 2025 01:28:34 +0530 [thread overview]
Message-ID: <20251004195834.1415468-1-madhurkumar004@gmail.com> (raw)
The test-statx program in samples/vfs/ includes both <stdio.h> and
usr/include/linux/fcntl.h, leading to redefinition errors for
AT_RENAME_NOREPLACE, AT_RENAME_EXCHANGE, and AT_RENAME_WHITEOUT. These
macros, defined in both glibc headers (via <stdio.h>, likely including
<fcntl.h>) and the kernel's usr/include/linux/fcntl.h, are not directly
used in test-statx.c but cause a build failure with -Werror due to
redefinition warnings like:
In file included from samples/vfs/test-statx.c:23:
usr/include/linux/fcntl.h:160:9: error: ‘AT_RENAME_NOREPLACE’ redefined [-Werror]
160 | #define AT_RENAME_NOREPLACE 0x0001
| ^~~~~~~~~~~~~~~~~~~
In file included from samples/vfs/test-statx.c:13:
/usr/include/stdio.h:171:10: note: this is the location of the previous definition
171 | # define AT_RENAME_NOREPLACE RENAME_NOREPLACE
| ^~~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:161:9: error: ‘AT_RENAME_EXCHANGE’ redefined [-Werror]
161 | #define AT_RENAME_EXCHANGE 0x0002
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:173:10: note: this is the location of the previous definition
173 | # define AT_RENAME_EXCHANGE RENAME_EXCHANGE
| ^~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:162:9: error: ‘AT_RENAME_WHITEOUT’ redefined [-Werror]
162 | #define AT_RENAME_WHITEOUT 0x0004
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:175:10: note: this is the location of the previous definition
175 | # define AT_RENAME_WHITEOUT RENAME_WHITEOUT
| ^~~~~~~~~~~~~~~~~~
Since test-statx relies on other kernel-specific definitions from
usr/include/linux/fcntl.h, this patch adds #undef directives for the
conflicting macros before including the kernel header, ensuring the
kernel's definitions are used without warnings.
Signed-off-by: Madhur Kumar <madhurkumar004@gmail.com>
---
samples/vfs/test-statx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c
index 49c7a46cee07..17332100a2b5 100644
--- a/samples/vfs/test-statx.c
+++ b/samples/vfs/test-statx.c
@@ -20,6 +20,9 @@
#include <sys/syscall.h>
#include <sys/types.h>
#include <linux/stat.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
--
2.51.0
reply other threads:[~2025-10-04 19:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20251004195834.1415468-1-madhurkumar004@gmail.com \
--to=madhurkumar004@gmail.com \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=geert+renesas@glider.be \
--cc=jlayton@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
all inboxes | Powered by JetHome®