summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/file.c b/file.c
index decb5ba81e..8db72a089a 100644
--- a/file.c
+++ b/file.c
@@ -2051,13 +2051,11 @@ rb_file_s_readlink(klass, path)
SafeStringValue(path);
buf = xmalloc(size);
- for (;;) {
- rv = readlink(RSTRING(path)->ptr, buf, size);
-#ifndef _AIX
- if (rv != size) break;
-#else
- if (rv > 0 || errno != ERANGE) break;
+ while ((rv = readlink(RSTRING(path)->ptr, buf, size)) == size
+#ifdef _AIX
+ || (rv < 0 && errno == ERANGE) /* quirky behavior of GPFS */
#endif
+ ) {
size *= 2;
buf = xrealloc(buf, size);
}