Skip to contentSkip to conversation

tools build: Fix timerfd feature detection with clang

PATCH Applied Ian Rogers 3 participants 3 messages Sep 10 – Sep 12

lore
Share & tools
lore

Ian Rogers

author
#0 lore raw

PATCH 1/1 tools build: Fix timerfd feature detection with clang

Clang's uninitialized-const-pointer warning causes a feature test to fail when building perf with clang. This disables support for 'perf kvm stat live'. Add default initialization to new_value as a workaround.

test-timerfd.c:15:30: error: variable 'new_value' is uninitialized when passed

			       as a const pointer argument here
			       [-Werror,-Wuninitialized-const-pointer]
     15 |         if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
        |                                     ^~~~~~~~~

1 error generated.

---
 tools/build/feature/test-timerfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/feature/test-timerfd.c +1 -1
index 9c72c697a9df..f88e8cc63ef3 100644
@@ -6,7 +6,7 @@
 
 int main(void)
 {
-	struct itimerspec new_value;
+	struct itimerspec new_value = {};
 
 	int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
 	if (fd < 0)
Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

Clang's uninitialized-const-pointer warning causes a feature test to fail when building perf with clang. This disables support for 'perf kvm stat live'. Add default initialization to new_value as a workaround.

Quoted 8 lines

test-timerfd.c:15:30: error: variable 'new_value' is uninitialized when passed

			       as a const pointer argument here
			       [-Werror,-Wuninitialized-const-pointer]
     15 |         if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
        |                                     ^~~~~~~~~

1 error generated.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Ian Rogers
Quoted 5 lines · Ian Rogers

Clang's uninitialized-const-pointer warning causes a feature test to fail when building perf with clang. This disables support for 'perf kvm stat live'. Add default initialization to new_value as a workaround.

Quoted 8 lines

test-timerfd.c:15:30: error: variable 'new_value' is uninitialized when passed

			       as a const pointer argument here
			       [-Werror,-Wuninitialized-const-pointer]
     15 |         if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
        |                                     ^~~~~~~~~

1 error generated.

Thanks, applied to perf-tools-next, for v7.4.

- Arnaldo

Quoted 20 lines
---
 tools/build/feature/test-timerfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/feature/test-timerfd.c +1 -1
index 9c72c697a9df..f88e8cc63ef3 100644
@@ -6,7 +6,7 @@
 
 int main(void)
 {
-	struct itimerspec new_value;
+	struct itimerspec new_value = {};
 
 	int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
 	if (fd < 0)
Signature · 1 line
2.55.0.1007.g17ff1f9808-goog