Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux_kselftest-fixes-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest fixes from Shuah Khan
"Fixes to clang build failures to timerns, vDSO tests and fixes to vDSO
makefile"

* tag 'linux_kselftest-fixes-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests/vDSO: remove duplicate compiler invocations from Makefile
selftests/vDSO: remove partially duplicated "all:" target in Makefile
selftests/vDSO: fix clang build errors and warnings
selftest/timerns: fix clang build failures for abs() calls

+46 -31
+3 -3
tools/testing/selftests/timens/exec.c
··· 30 30 31 31 for (i = 0; i < 2; i++) { 32 32 _gettime(CLOCK_MONOTONIC, &tst, i); 33 - if (abs(tst.tv_sec - now.tv_sec) > 5) 33 + if (labs(tst.tv_sec - now.tv_sec) > 5) 34 34 return pr_fail("%ld %ld\n", now.tv_sec, tst.tv_sec); 35 35 } 36 36 return 0; ··· 50 50 51 51 for (i = 0; i < 2; i++) { 52 52 _gettime(CLOCK_MONOTONIC, &tst, i); 53 - if (abs(tst.tv_sec - now.tv_sec) > 5) 53 + if (labs(tst.tv_sec - now.tv_sec) > 5) 54 54 return pr_fail("%ld %ld\n", 55 55 now.tv_sec, tst.tv_sec); 56 56 } ··· 70 70 /* Check that a child process is in the new timens. */ 71 71 for (i = 0; i < 2; i++) { 72 72 _gettime(CLOCK_MONOTONIC, &tst, i); 73 - if (abs(tst.tv_sec - now.tv_sec - OFFSET) > 5) 73 + if (labs(tst.tv_sec - now.tv_sec - OFFSET) > 5) 74 74 return pr_fail("%ld %ld\n", 75 75 now.tv_sec + OFFSET, tst.tv_sec); 76 76 }
+1 -1
tools/testing/selftests/timens/timer.c
··· 56 56 return pr_perror("timerfd_gettime"); 57 57 58 58 elapsed = new_value.it_value.tv_sec; 59 - if (abs(elapsed - 3600) > 60) { 59 + if (llabs(elapsed - 3600) > 60) { 60 60 ksft_test_result_fail("clockid: %d elapsed: %lld\n", 61 61 clockid, elapsed); 62 62 return 1;
+1 -1
tools/testing/selftests/timens/timerfd.c
··· 61 61 return pr_perror("timerfd_gettime(%d)", clockid); 62 62 63 63 elapsed = new_value.it_value.tv_sec; 64 - if (abs(elapsed - 3600) > 60) { 64 + if (llabs(elapsed - 3600) > 60) { 65 65 ksft_test_result_fail("clockid: %d elapsed: %lld\n", 66 66 clockid, elapsed); 67 67 return 1;
+2 -2
tools/testing/selftests/timens/vfork_exec.c
··· 32 32 33 33 for (i = 0; i < 2; i++) { 34 34 _gettime(CLOCK_MONOTONIC, &tst, i); 35 - if (abs(tst.tv_sec - now->tv_sec) > 5) { 35 + if (labs(tst.tv_sec - now->tv_sec) > 5) { 36 36 pr_fail("%s: in-thread: unexpected value: %ld (%ld)\n", 37 37 args->tst_name, tst.tv_sec, now->tv_sec); 38 38 return (void *)1UL; ··· 64 64 65 65 for (i = 0; i < 2; i++) { 66 66 _gettime(CLOCK_MONOTONIC, &tst, i); 67 - if (abs(tst.tv_sec - now->tv_sec) > 5) 67 + if (labs(tst.tv_sec - now->tv_sec) > 5) 68 68 return pr_fail("%s: unexpected value: %ld (%ld)\n", 69 69 tst_name, tst.tv_sec, now->tv_sec); 70 70 }
+12 -17
tools/testing/selftests/vDSO/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - include ../lib.mk 3 - 4 2 uname_M := $(shell uname -m 2>/dev/null || echo not) 5 3 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) 6 4 7 - TEST_GEN_PROGS := $(OUTPUT)/vdso_test_gettimeofday $(OUTPUT)/vdso_test_getcpu 8 - TEST_GEN_PROGS += $(OUTPUT)/vdso_test_abi 9 - TEST_GEN_PROGS += $(OUTPUT)/vdso_test_clock_getres 5 + TEST_GEN_PROGS := vdso_test_gettimeofday 6 + TEST_GEN_PROGS += vdso_test_getcpu 7 + TEST_GEN_PROGS += vdso_test_abi 8 + TEST_GEN_PROGS += vdso_test_clock_getres 10 9 ifeq ($(ARCH),$(filter $(ARCH),x86 x86_64)) 11 - TEST_GEN_PROGS += $(OUTPUT)/vdso_standalone_test_x86 10 + TEST_GEN_PROGS += vdso_standalone_test_x86 12 11 endif 13 - TEST_GEN_PROGS += $(OUTPUT)/vdso_test_correctness 12 + TEST_GEN_PROGS += vdso_test_correctness 14 13 15 14 CFLAGS := -std=gnu99 16 - CFLAGS_vdso_standalone_test_x86 := -nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector 17 - LDFLAGS_vdso_test_correctness := -ldl 15 + 18 16 ifeq ($(CONFIG_X86_32),y) 19 17 LDLIBS += -lgcc_s 20 18 endif 21 19 22 - all: $(TEST_GEN_PROGS) 20 + include ../lib.mk 23 21 $(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c 24 22 $(OUTPUT)/vdso_test_getcpu: parse_vdso.c vdso_test_getcpu.c 25 23 $(OUTPUT)/vdso_test_abi: parse_vdso.c vdso_test_abi.c 26 24 $(OUTPUT)/vdso_test_clock_getres: vdso_test_clock_getres.c 25 + 27 26 $(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c 28 - $(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \ 29 - vdso_standalone_test_x86.c parse_vdso.c \ 30 - -o $@ 27 + $(OUTPUT)/vdso_standalone_test_x86: CFLAGS +=-nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector 28 + 31 29 $(OUTPUT)/vdso_test_correctness: vdso_test_correctness.c 32 - $(CC) $(CFLAGS) \ 33 - vdso_test_correctness.c \ 34 - -o $@ \ 35 - $(LDFLAGS_vdso_test_correctness) 30 + $(OUTPUT)/vdso_test_correctness: LDFLAGS += -ldl
+11 -5
tools/testing/selftests/vDSO/parse_vdso.c
··· 55 55 ELF(Verdef) *verdef; 56 56 } vdso_info; 57 57 58 - /* Straight from the ELF specification. */ 59 - static unsigned long elf_hash(const unsigned char *name) 58 + /* 59 + * Straight from the ELF specification...and then tweaked slightly, in order to 60 + * avoid a few clang warnings. 61 + */ 62 + static unsigned long elf_hash(const char *name) 60 63 { 61 64 unsigned long h = 0, g; 62 - while (*name) 65 + const unsigned char *uch_name = (const unsigned char *)name; 66 + 67 + while (*uch_name) 63 68 { 64 - h = (h << 4) + *name++; 65 - if (g = h & 0xf0000000) 69 + h = (h << 4) + *uch_name++; 70 + g = h & 0xf0000000; 71 + if (g) 66 72 h ^= g >> 24; 67 73 h &= ~g; 68 74 }
+16 -2
tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
··· 18 18 19 19 #include "parse_vdso.h" 20 20 21 - /* We need a libc functions... */ 21 + /* We need some libc functions... */ 22 22 int strcmp(const char *a, const char *b) 23 23 { 24 24 /* This implementation is buggy: it never returns -1. */ ··· 32 32 } 33 33 34 34 return 0; 35 + } 36 + 37 + /* 38 + * The clang build needs this, although gcc does not. 39 + * Stolen from lib/string.c. 40 + */ 41 + void *memcpy(void *dest, const void *src, size_t count) 42 + { 43 + char *tmp = dest; 44 + const char *s = src; 45 + 46 + while (count--) 47 + *tmp++ = *s++; 48 + return dest; 35 49 } 36 50 37 51 /* ...and two syscalls. This is x86-specific. */ ··· 84 70 } 85 71 } 86 72 87 - __attribute__((externally_visible)) void c_main(void **stack) 73 + void c_main(void **stack) 88 74 { 89 75 /* Parse the stack */ 90 76 long argc = (long)*stack;