From 2a462733cacf4f1618e32820bd3fcf02b472875c Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 28 Jul 2016 17:29:13 +0200 Subject: [PATCH] src/h5core/private/h5_file.h - is_writable() is now static inline not a macro - macro CHECK_READABLE_MODE() added --- src/h5core/private/h5_file.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/h5core/private/h5_file.h b/src/h5core/private/h5_file.h index 0c46162..b82bd9f 100644 --- a/src/h5core/private/h5_file.h +++ b/src/h5core/private/h5_file.h @@ -32,7 +32,9 @@ check_filehandle ( #define CHECK_FILEHANDLE(f) \ TRY (check_filehandle (f)); -#define is_writable(f) (f->props->flags & (H5_O_RDWR | H5_O_WRONLY | H5_O_APPENDONLY)) +static inline int is_writable(h5_file_p f) { + return (f->props->flags & (H5_O_RDWR | H5_O_WRONLY | H5_O_APPENDONLY)); +} #define is_readable(f) (f->props->flags & (H5_O_RDWR | H5_O_RDONLY)) #define is_readonly(f) (f->props->flags & H5_O_RDONLY) #define is_appendonly(f) (f->props->flags & H5_O_APPENDONLY) @@ -40,7 +42,12 @@ check_filehandle ( #define CHECK_WRITABLE_MODE(f) \ TRY (is_writable (f) ? H5_SUCCESS : h5_error ( \ H5_ERR_INVAL, \ - "Attempting to write to read-only file")); + "Attempting to write to read-only file handle")); + +#define CHECK_READABLE_MODE(f) \ + TRY (is_readable (f) ? H5_SUCCESS : h5_error ( \ + H5_ERR_INVAL, \ + "Attempting to read from write-only file handle")); #define CHECK_TIMEGROUP(f) \ TRY ((f->step_gid > 0) ? H5_SUCCESS : h5_error ( \