diff mbox series

[v2,1/3] utest/tracefs-utest: include linux/limits.h

Message ID 20240222-utest-fixes-v2-1-ba9cd06b41d3@gmail.com (mailing list archive)
State Superseded
Headers show
Series utest: fix build with musl + clang >=15 | expand

Commit Message

Miko Larsson via B4 Relay Feb. 22, 2024, 10:12 a.m. UTC
From: Miko Larsson <mikoxyzzz@gmail.com>

This fixes the build with musl + clang >=15; musl doesn't define
PATH_MAX anywhere else, and clang >=15 doesn't allow implicit
declarations with >=c99. Without this, the build fails due to PATH_MAX
not being defined.

We could include limits.h from the libc, but AFAIK the libc doesn't
necessarily have to define PATH_MAX, so it's safer to just include
linux/limits.h

Fixes: 845f16976929 ("libtracefs: Add unit tests")
Signed-off-by: Miko Larsson <mikoxyzzz@gmail.com>
---
 utest/tracefs-utest.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Steven Rostedt Feb. 22, 2024, 2:53 p.m. UTC | #1
On Thu, 22 Feb 2024 11:12:44 +0100
Miko Larsson via B4 Relay <devnull+mikoxyzzz.gmail.com@kernel.org> wrote:

> From: Miko Larsson <mikoxyzzz@gmail.com>
> 
> This fixes the build with musl + clang >=15; musl doesn't define
> PATH_MAX anywhere else, and clang >=15 doesn't allow implicit
> declarations with >=c99. Without this, the build fails due to PATH_MAX
> not being defined.
> 
> We could include limits.h from the libc, but AFAIK the libc doesn't
> necessarily have to define PATH_MAX, so it's safer to just include
> linux/limits.h

Actually, the way I handle PATH_MAX is to add:

#ifndef PATH_MAX
#define PATH_MAX 1024
#endif

As it's not really used, but just a default value to be able to add any
paths used in the tracefs directory, where 1024 is more than enough.

-- Steve
Steven Rostedt Feb. 22, 2024, 4:04 p.m. UTC | #2
On Thu, 22 Feb 2024 09:53:45 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Thu, 22 Feb 2024 11:12:44 +0100
> Miko Larsson via B4 Relay <devnull+mikoxyzzz.gmail.com@kernel.org> wrote:
> 
> > From: Miko Larsson <mikoxyzzz@gmail.com>
> > 
> > This fixes the build with musl + clang >=15; musl doesn't define
> > PATH_MAX anywhere else, and clang >=15 doesn't allow implicit
> > declarations with >=c99. Without this, the build fails due to PATH_MAX
> > not being defined.
> > 
> > We could include limits.h from the libc, but AFAIK the libc doesn't
> > necessarily have to define PATH_MAX, so it's safer to just include
> > linux/limits.h  
> 
> Actually, the way I handle PATH_MAX is to add:
> 
> #ifndef PATH_MAX
> #define PATH_MAX 1024
> #endif
> 
> As it's not really used, but just a default value to be able to add any
> paths used in the tracefs directory, where 1024 is more than enough.

I'm going to apply your other two patches, but I created a patch with the
added code above, and will be posting that shortly.

-- Steve
Miko Larsson Feb. 22, 2024, 5:24 p.m. UTC | #3
On Thu Feb 22, 2024 at 5:04 PM CET, Steven Rostedt wrote:
> I'm going to apply your other two patches, but I created a patch with the
> added code above, and will be posting that shortly.
Thanks!
diff mbox series

Patch

diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 963fac7..70bcf3e 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -16,6 +16,8 @@ 
 #include <kbuffer.h>
 #include <pthread.h>
 
+#include <linux/limits.h>
+
 #include <sys/mount.h>
 #include <sys/syscall.h>