Messages in this thread Patch in this message | | | Subject | [PATCH 4/4] x86, selftests: fix protection keys write() warining | From | Dave Hansen <> | Date | Fri, 10 Nov 2017 16:12:32 -0800 |
| |
From: Dave Hansen <dave.hansen@linux.intel.com>
write() is marked as having a must-check return value. Check it and abort if we fail to write an error message from a signal handler.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> ---
b/tools/testing/selftests/x86/pkey-helpers.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff -puN tools/testing/selftests/x86/pkey-helpers.h~x86-selftests-protection-keys-write-warning tools/testing/selftests/x86/pkey-helpers.h --- a/tools/testing/selftests/x86/pkey-helpers.h~x86-selftests-protection-keys-write-warning 2017-11-10 15:29:29.240207938 -0800 +++ b/tools/testing/selftests/x86/pkey-helpers.h 2017-11-10 15:29:29.244207938 -0800 @@ -30,6 +30,7 @@ static inline void sigsafe_printf(const if (!dprint_in_signal) { vprintf(format, ap); } else { + int ret; int len = vsnprintf(dprint_in_signal_buffer, DPRINT_IN_SIGNAL_BUF_SIZE, format, ap); @@ -39,7 +40,9 @@ static inline void sigsafe_printf(const */ if (len > DPRINT_IN_SIGNAL_BUF_SIZE) len = DPRINT_IN_SIGNAL_BUF_SIZE; - write(1, dprint_in_signal_buffer, len); + ret = write(1, dprint_in_signal_buffer, len); + if (ret < 0) + abort(); } va_end(ap); } _
| |