summaryrefslogtreecommitdiff
path: root/ext/stringio
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-23 08:57:48 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-23 08:57:48 (GMT)
commitf4166e2dd7a4d9be95f160e19303ddeeb5d27ab4 (patch)
tree54a609327994753d5579a07797f199fff86c3dc4 /ext/stringio
parentd15f30882ae8cd6acd27fed5cbb046b5c7c15549 (diff)
prefer rb_syserr_fail
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno over setting errno then call rb_sys_fail, not to be clobbered potentially and to reduce thread local errno accesses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/stringio')
-rw-r--r--ext/stringio/stringio.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 3a14716..23c4356 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -33,7 +33,7 @@ static void strio_init(int, VALUE *, struct StringIO *, VALUE);
static VALUE strio_unget_bytes(struct StringIO *, const char *, long);
#define IS_STRIO(obj) (rb_typeddata_is_kind_of((obj), &strio_data_type))
-#define error_inval(msg) (errno = EINVAL, rb_sys_fail(msg))
+#define error_inval(msg) (rb_syserr_fail(EINVAL, msg))
#define get_enc(ptr) ((ptr)->enc ? (ptr)->enc : rb_enc_get((ptr)->string))
static struct StringIO *
@@ -195,8 +195,7 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
}
StringValue(string);
if ((ptr->flags & FMODE_WRITABLE) && OBJ_FROZEN(string)) {
- errno = EACCES;
- rb_sys_fail(0);
+ rb_syserr_fail(EACCES, 0);
}
if (trunc) {
rb_str_resize(string, 0);