Skip to content

Commit

Permalink
Suppress unused-result warnings
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
S-H-GAMELINKS and nobu committed Aug 7, 2021
1 parent e5dd40b commit 9b3fcfb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions spec/ruby/optional/capi/ext/string_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9b3fcfb

Please sign in to comment.