summaryrefslogtreecommitdiff
path: root/lib/safe-read.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-12-03 09:48:14 +0000
committerJim Meyering <jim@meyering.net>2002-12-03 09:48:14 +0000
commit3336e16fb39ca0fafa5185797f0f0b9431c2330d (patch)
tree4ce066ecb132fc35f77ab39df680fa1100adaf70 /lib/safe-read.c
parent2cb98f7c62c63eedab93f2a0cc53383c5d8af9f0 (diff)
downloadgnulib-3336e16fb39ca0fafa5185797f0f0b9431c2330d.tar.gz
(IS_EINTR): Define.
(safe_read): Use IS_EINTR in place of in-function cpp directives.
Diffstat (limited to 'lib/safe-read.c')
-rw-r--r--lib/safe-read.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/safe-read.c b/lib/safe-read.c
index 0d0f29dddf..5d2cd9dded 100644
--- a/lib/safe-read.c
+++ b/lib/safe-read.c
@@ -33,6 +33,12 @@
extern int errno;
#endif
+#ifdef EINTR
+# define IS_EINTR(x) ((x) == EINTR)
+#else
+# define IS_EINTR(x) 0
+#endif
+
#include <limits.h>
#ifndef CHAR_BIT
@@ -77,11 +83,7 @@ safe_read (int fd, void *buf, size_t count)
{
result = read (fd, buf, nbytes_to_read);
}
-#ifdef EINTR
- while (result < 0 && errno == EINTR);
-#else
- while (0);
-#endif
+ while (result < 0 && IS_EINTR (errno));
return (size_t) result;
}