Skip to contentSkip to conversation

utest: fix FTBFS with clang >=15

PATCH Superseded Miko Larsson 2 participants 8 messages Feb 15, 2024 – Feb 22, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover utest: fix FTBFS with clang >=15

Clang 15 onwards defaults to -Werror=implicit-function-declaration, which breaks the utest build. This series fixes that by simply adding the missing include and define directives.

---
Miko Larsson (3):
utest/tracefs-utest: add missing include
utest/tracefs-utest: add missing define
utest/trace-utest: add missing include

 utest/trace-utest.c   | 1 +
 utest/tracefs-utest.c | 4 ++++
 2 files changed, 5 insertions(+)

---
base-commit: 5f27b7f3fb7d88b29522baf3883cc0e2e28b1af0
change-id: 20240215-utest-fixes-893315be225b

Best regards,

Signature · 1 line
Miko Larsson <[email protected]>
#1 lore raw

PATCH 1/3 utest/tracefs-utest: add missing include

Fixes FTBFS with clang >=15

Fixes 845f16976929 ("libtracefs: Add unit tests")
---
 utest/tracefs-utest.c | 2 ++
 1 file changed, 2 insertions(+)
utest/tracefs-utest.c +2 -0
index 963fac7..a798ace 100644
@@ -19,6 +19,8 @@
 #include <sys/mount.h>
 #include <sys/syscall.h>
 
+#include <linux/limits.h>
+
 #include <CUnit/CUnit.h>
 #include <CUnit/Basic.h>
 
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/3] utest/tracefs-utest: add missing include

Quoted 1 line · On Thu, 15 Feb 2024 10:02:41 +0100 Miko Larsson via B4 Relay…

From: Miko Larsson <[email protected]>

Hi Miko,

Quoted 2 lines

Fixes FTBFS with clang >=15

What exactly is this fixing. I tried building the tests with clang 16 and I don't get any errors. Please show the error that you have without this change.

-- Steve

Quoted 21 lines
Fixes 845f16976929 ("libtracefs: Add unit tests")
---
 utest/tracefs-utest.c | 2 ++
 1 file changed, 2 insertions(+)
utest/tracefs-utest.c +2 -0
index 963fac7..a798ace 100644
@@ -19,6 +19,8 @@
 #include <sys/mount.h>
 #include <sys/syscall.h>
 
+#include <linux/limits.h>
+
 #include <CUnit/CUnit.h>
 #include <CUnit/Basic.h>
 
#3 lore raw

Re: [PATCH 1/3] utest/tracefs-utest: add missing include

Quoted 3 lines · Steven Rostedt

What exactly is this fixing. I tried building the tests with clang 16 and I don't get any errors. Please show the error that you have without this change.

Hm, yeah, could be that this occurs with clang >16, not sure though.

Following is the error I get with clang 18 without this patch applied:
FAILED: utest/trace-utest.p/tracefs-utest.c.o
clang -Iutest/trace-utest.p -Iutest -I../utest -Iinclude -I../include -I/usr/include/traceevent -flto=thin -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu99 -D_GNU_SOURCE -Wformat -Werror=format-security -ftrivial-auto-var-init=zero -fstack-clash-protection -fsanitize=signed-integer-overflow,integer-divide-by-zero -fsanitize-trap=signed-integer-overflow,integer-divide-by-zero -fno-sanitize-recover -flto=thin -O2 -ffile-prefix-map=/builddir/libtracefs-1.8.0=. -g2 -pthread -MD -MQ utest/trace-utest.p/tracefs-utest.c.o -MF utest/trace-utest.p/tracefs-utest.c.o.d -o utest/trace-utest.p/tracefs-utest.c.o -c ../utest/tracefs-utest.c ../utest/tracefs-utest.c:2494:12: error: use of undeclared identifier 'PATH_MAX'
2494 | char self[PATH_MAX] = { 0 };
| ^
../utest/tracefs-utest.c:2850:12: error: use of undeclared identifier 'PATH_MAX'
2850 | char link[PATH_MAX + 1];
| ^
../utest/tracefs-utest.c:2851:12: error: use of undeclared identifier 'PATH_MAX'
2851 | char path[PATH_MAX + 1];
| ^
../utest/tracefs-utest.c:2856:17: error: use of undeclared identifier 'PATH_MAX'
2856 | snprintf(link, PATH_MAX, "/proc/self/fd/%d", fd);
| ^
../utest/tracefs-utest.c:2864:29: error: use of undeclared identifier 'PATH_MAX'
2864 | ret = readlink(link, path, PATH_MAX);
| ^
../utest/tracefs-utest.c:2866:12: error: use of undeclared identifier 'PATH_MAX'
2866 | if (ret > PATH_MAX || ret < 0)
| ^
../utest/tracefs-utest.c:2887:12: error: use of undeclared identifier 'PATH_MAX'
2887 | char path[PATH_MAX + 1];
| ^
../utest/tracefs-utest.c:2896:17: error: use of undeclared identifier 'PATH_MAX'
2896 | snprintf(path, PATH_MAX, "/proc/self/fdinfo/%d", fd);
| ^
../utest/tracefs-utest.c:3028:12: error: use of undeclared identifier 'PATH_MAX'
3028 | char file[PATH_MAX];
| ^
../utest/tracefs-utest.c:3043:17: error: use of undeclared identifier 'PATH_MAX'
3043 | snprintf(file, PATH_MAX, "options/%s", name);
| ^
../utest/tracefs-utest.c:3092:12: error: use of undeclared identifier 'PATH_MAX'
3092 | char file[PATH_MAX];
| ^
../utest/tracefs-utest.c:3112:18: error: use of undeclared identifier 'PATH_MAX'
3112 | snprintf(file, PATH_MAX, "options/%s", name);
| ^
../utest/tracefs-utest.c:3256:12: error: use of undeclared identifier 'PATH_MAX'
3256 | char file[PATH_MAX];
| ^
../utest/tracefs-utest.c:3460:12: error: use of undeclared identifier 'PATH_MAX'
3460 | char path[PATH_MAX];
| ^
../utest/tracefs-utest.c:3480:17: error: use of undeclared identifier 'PATH_MAX'
3480 | char file_from[PATH_MAX];
| ^
../utest/tracefs-utest.c:3481:15: error: use of undeclared identifier 'PATH_MAX'
3481 | char file_to[PATH_MAX];
| ^
../utest/tracefs-utest.c:3493:17: error: use of undeclared identifier 'PATH_MAX'
3493 | char file_from[PATH_MAX];
| ^
../utest/tracefs-utest.c:3494:15: error: use of undeclared identifier 'PATH_MAX'
3494 | char file_to[PATH_MAX];
| ^
18 errors generated.

#4 lore raw

PATCH 2/3 utest/tracefs-utest: add missing define

In reply to Miko Larsson

Fixes FTBFS with clang >=15

Fixes 0f45e68cb04a ("libtracefs: Add unit tests for tracefs_cpu functions")
---
 utest/tracefs-utest.c | 2 ++
 1 file changed, 2 insertions(+)
utest/tracefs-utest.c +2 -0
index a798ace..e30e8e7 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2020, VMware, Tzvetomir Stoyanov <[email protected]>
  *
  */
+#define _LARGEFILE64_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH 2/3] utest/tracefs-utest: add missing define

Quoted 3 lines · On Thu, 15 Feb 2024 10:02:42 +0100 Miko Larsson via B4 Relay…

From: Miko Larsson <[email protected]>

Fixes FTBFS with clang >=15

FTBFS is a rather useless explanation (and I had to even look it up to find out what it is ;-)

The change log should show the error and explain why the change fixes the problem.

Thanks,

-- Steve

Quoted 21 lines
Fixes 0f45e68cb04a ("libtracefs: Add unit tests for tracefs_cpu functions")
---
 utest/tracefs-utest.c | 2 ++
 1 file changed, 2 insertions(+)
utest/tracefs-utest.c +2 -0
index a798ace..e30e8e7 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2020, VMware, Tzvetomir Stoyanov <[email protected]>
  *
  */
+#define _LARGEFILE64_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
#6 lore raw

Re: [PATCH 2/3] utest/tracefs-utest: add missing define

Quoted 5 lines · Steven Rostedt

FTBFS is a rather useless explanation (and I had to even look it up to find out what it is ;-)

The change log should show the error and explain why the change fixes the problem.

Heh, yeah, you're right. Thanks.

#7 lore raw

PATCH 3/3 utest/trace-utest: add missing include

In reply to Miko Larsson

Fixes FTBFS with clang >=15

Fixes 845f16976929 ("libtracefs: Add unit tests")
---
 utest/trace-utest.c | 1 +
 1 file changed, 1 insertion(+)
utest/trace-utest.c +1 -0
index 58d4d4e..39485a1 100644
@@ -3,6 +3,7 @@
  * Copyright (C) 2020, VMware, Tzvetomir Stoyanov <[email protected]>
  *
  */
+#include <libgen.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <getopt.h>
Signature · 1 line
2.43.0