* [PATCH] libtracefs: Remove include sys/stat.h from global tracefs.h
@ 2021-08-04 14:30 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2021-08-04 14:30 UTC (permalink / raw)
To: linux-trace-devel@vger.kernel.org
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-04 14:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-04 14:30 [PATCH] libtracefs: Remove include sys/stat.h from global tracefs.h Steven Rostedt
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).