[PATCH v2 6/7] selftests/bpf: replace "__auto_type" with "auto"

H. Peter Anvin posted 7 patches 2 months, 2 weeks ago
[PATCH v2 6/7] selftests/bpf: replace "__auto_type" with "auto"
Posted by H. Peter Anvin 2 months, 2 weeks ago
Replace instances of "__auto_type" with "auto" in:

	tools/testing/selftests/bpf/prog_tests/socket_helpers.h

This file does not seem to be including <linux/compiler_types.h>
directly or indirectly, so copy the definition but guard it with
!defined(auto).

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
 tools/testing/selftests/bpf/prog_tests/socket_helpers.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/socket_helpers.h b/tools/testing/selftests/bpf/prog_tests/socket_helpers.h
index e02cabcc814e..0d59503a0c73 100644
--- a/tools/testing/selftests/bpf/prog_tests/socket_helpers.h
+++ b/tools/testing/selftests/bpf/prog_tests/socket_helpers.h
@@ -17,11 +17,16 @@
 #define VMADDR_CID_LOCAL 1
 #endif
 
+/* include/linux/compiler_types.h */
+#if __STDC_VERSION__ < 202311L && !defined(auto)
+# define auto __auto_type
+#endif
+
 /* include/linux/cleanup.h */
 #define __get_and_null(p, nullvalue)                                           \
 	({                                                                     \
-		__auto_type __ptr = &(p);                                      \
-		__auto_type __val = *__ptr;                                    \
+		auto __ptr = &(p);					       \
+		auto __val = *__ptr;                                           \
 		*__ptr = nullvalue;                                            \
 		__val;                                                         \
 	})
-- 
2.50.1
Re: [PATCH v2 6/7] selftests/bpf: replace "__auto_type" with "auto"
Posted by Eduard Zingerman 2 months, 2 weeks ago
On Sat, 2025-07-19 at 23:50 -0700, H. Peter Anvin wrote:
> Replace instances of "__auto_type" with "auto" in:
> 
> 	tools/testing/selftests/bpf/prog_tests/socket_helpers.h
> 
> This file does not seem to be including <linux/compiler_types.h>
> directly or indirectly, so copy the definition but guard it with
> !defined(auto).
> 
> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
> ---

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

[...]