From 56943deb88ae2efb82b8d78c8fede1b34e48f28e Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 10 Feb 2011 06:02:46 -0800 Subject: [PATCH] common/safe_io.h: warn about unchecked returns Signed-off-by: Colin McCabe --- src/common/safe_io.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/common/safe_io.h b/src/common/safe_io.h index 8f89b0881088b..3a975d72b9093 100644 --- a/src/common/safe_io.h +++ b/src/common/safe_io.h @@ -25,17 +25,23 @@ extern "C" { * These retry on EINTR, and on error return -errno instead of returning * 1 and setting errno). */ - ssize_t safe_read(int fd, void *buf, size_t count); - ssize_t safe_write(int fd, const void *buf, size_t count); - ssize_t safe_pread(int fd, void *buf, size_t count, off_t offset); - ssize_t safe_pwrite(int fd, const void *buf, size_t count, off_t offset); + ssize_t safe_read(int fd, void *buf, size_t count) + __attribute__ ((warn_unused_result)); + ssize_t safe_write(int fd, const void *buf, size_t count) + __attribute__ ((warn_unused_result)); + ssize_t safe_pread(int fd, void *buf, size_t count, off_t offset) + __attribute__ ((warn_unused_result)); + ssize_t safe_pwrite(int fd, const void *buf, size_t count, off_t offset) + __attribute__ ((warn_unused_result)); /* * Same as the above functions, but return -EDOM unless exactly the requested * number of bytes can be read. */ - ssize_t safe_read_exact(int fd, void *buf, size_t count); - ssize_t safe_pread_exact(int fd, void *buf, size_t count, off_t offset); + ssize_t safe_read_exact(int fd, void *buf, size_t count) + __attribute__ ((warn_unused_result)); + ssize_t safe_pread_exact(int fd, void *buf, size_t count, off_t offset) + __attribute__ ((warn_unused_result)); #ifdef __cplusplus } -- 2.39.5