diff options
author | S.H <gamelinks007@gmail.com> | 2021-08-07 12:50:55 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-07 12:50:55 +0900 |
commit | 9b3fcfbbb9031036a9f7ba8ae1934f0805ea4d85 (patch) | |
tree | 8133bcabdf7f3fec738906073bc7d80a90641b83 /spec/ruby | |
parent | e5dd40b1f3a11f48d566413ab347ce0cfdd94960 (diff) | |
download | ruby-9b3fcfbbb9031036a9f7ba8ae1934f0805ea4d85.tar.gz |
Suppress unused-result warnings
* Hide read function warning in string_spec_RSTRING_PTR_read function
* The type of `read` may be `ssize_t`
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Diffstat (limited to 'spec/ruby')
-rw-r--r-- | spec/ruby/optional/capi/ext/string_spec.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/spec/ruby/optional/capi/ext/string_spec.c b/spec/ruby/optional/capi/ext/string_spec.c index b7bfcf8c88..feacbbdbb7 100644 --- a/spec/ruby/optional/capi/ext/string_spec.c +++ b/spec/ruby/optional/capi/ext/string_spec.c @@ -397,12 +397,16 @@ VALUE string_spec_RSTRING_PTR_read(VALUE self, VALUE str, VALUE path) { rb_str_modify_expand(str, 30); rb_ary_push(capacities, SIZET2NUM(rb_str_capacity(str))); char *buffer = RSTRING_PTR(str); - read(fd, buffer, 30); + if (read(fd, buffer, 30) < 0) { + rb_syserr_fail(errno, "read"); + } rb_str_modify_expand(str, 53); rb_ary_push(capacities, SIZET2NUM(rb_str_capacity(str))); char *buffer2 = RSTRING_PTR(str); - read(fd, buffer2 + 30, 53 - 30); + if (read(fd, buffer2 + 30, 53 - 30) < 0) { + rb_syserr_fail(errno, "read"); + } rb_str_set_len(str, 53); close(fd); |