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

selftests/timers: Quiet warning due to lack of return check on brk

The posix_timers.c test has a loop that tries to keep it in
kernel space, repeatedly calling brk(). However, it doesn't
check the return value, which causes warnings.

This patch adds a err value which captures the return value
and modifies the test so it will quit if a failure occurs.

Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Tested-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>

authored by

John Stultz and committed by
Shuah Khan
2430ec65 03438212

+4 -5
+4 -5
tools/testing/selftests/timers/posix_timers.c
··· 35 35 static void kernel_loop(void) 36 36 { 37 37 void *addr = sbrk(0); 38 + int err = 0; 38 39 39 - while (!done) { 40 - brk(addr + 4096); 41 - brk(addr); 40 + while (!done && !err) { 41 + err = brk(addr + 4096); 42 + err |= brk(addr); 42 43 } 43 44 } 44 45 ··· 191 190 192 191 int main(int argc, char **argv) 193 192 { 194 - int err; 195 - 196 193 printf("Testing posix timers. False negative may happen on CPU execution \n"); 197 194 printf("based timers if other threads run on the CPU...\n"); 198 195