From: Steven Rostedt <rostedt@goodmis.org>
To: "linux-trace-devel@vger.kernel.org" <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] libtracefs: Remove include sys/stat.h from global tracefs.h
Date: Wed, 4 Aug 2021 10:30:46 -0400 [thread overview]
Message-ID: <20210804103046.5e5a174d@oasis.local.home> (raw)
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
When using libtracefs in a program, Adding the following:
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tracefs.h>
Caused the following error:
In file included from /usr/include/bits/statx.h:31,
from /usr/include/sys/stat.h:446,
from /usr/local/include/tracefs/tracefs.h:9,
/usr/include/linux/stat.h:57:2: error: unknown type name â__s64â
57 | __s64 tv_sec;
| ^~~~~
The #define _GNU_SOURCE appears to cause this, but I needed it for my
program. I tried several combinations to fix it, but the only solution
I found that worked was to remove <sys/stat.h> from tracefs.h.
There's no reason to have it in the global header. The only includes that a
header should have are those that the header itself needed. As tracefs.h
does not need sys/stat.h itself, it should be removed.
Fixes: 4b05ae03 ("libtracefs: Add missing system includes")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
include/tracefs.h | 1 -
src/tracefs-tools.c | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/tracefs.h b/include/tracefs.h
index 55f8239..0e31a4f 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -6,7 +6,6 @@
#ifndef _TRACE_FS_H
#define _TRACE_FS_H
-#include <sys/stat.h>
#include <fcntl.h>
#include <sched.h>
#include <event-parse.h>
diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c
index ca0ed58..ae85444 100644
--- a/src/tracefs-tools.c
+++ b/src/tracefs-tools.c
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <regex.h>
#include <dirent.h>
#include <limits.h>
--
2.31.1
reply other threads:[~2021-08-04 14:32 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=20210804103046.5e5a174d@oasis.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@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).