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

kselftest/arm64: mte: user_mem: Fix write() warning

Out of the box Ubuntu's 20.04 compiler warns about missing return value
checks for write() (sys)calls.

Make GCC happy by checking whether we actually managed to write "val".

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Mark Brown <broone@kernel.org>
Link: https://lore.kernel.org/r/20210319165334.29213-5-andre.przywara@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Andre Przywara and committed by
Catalin Marinas
46cb11b1 31c88729

+2 -1
+2 -1
tools/testing/selftests/arm64/mte/check_user_mem.c
··· 33 33 if (fd == -1) 34 34 return KSFT_FAIL; 35 35 for (i = 0; i < len; i++) 36 - write(fd, &val, sizeof(val)); 36 + if (write(fd, &val, sizeof(val)) != sizeof(val)) 37 + return KSFT_FAIL; 37 38 lseek(fd, 0, 0); 38 39 ptr = mte_allocate_memory(len, mem_type, mapping, true); 39 40 if (check_allocated_memory(ptr, len, mem_type, true) != KSFT_PASS) {