1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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>
This commit is contained in:
S.H 2021-08-07 12:50:55 +09:00 committed by GitHub
parent e5dd40b1f3
commit 9b3fcfbbb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2021-08-07 12:51:16 +09:00
Merged: https://github.com/ruby/ruby/pull/4703

Merged-By: nobu <nobu@ruby-lang.org>

View file

@ -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);