Skip to content

Commit

Permalink
Fix sign-conversion warnings on IL32 platforms
Browse files Browse the repository at this point in the history
If `long` and `int` are the same size, `unsigned int` max would exceed
`signed long` range.  It is guaranteed by `RB_POSFIXABLE` that `v` can
be casted to `long` safely here.
  • Loading branch information
nobu committed Nov 10, 2024
1 parent e8accdb commit 2f88a92
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/ruby/internal/arithmetic/int.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static inline VALUE
rb_uint2num_inline(unsigned int v)
{
if (RB_POSFIXABLE(v))
return RB_LONG2FIX(v);
return RB_LONG2FIX(RBIMPL_CAST((long)v));
else
return rb_uint2big(v);
}
Expand Down
2 changes: 1 addition & 1 deletion include/ruby/internal/intern/select/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ rb_fd_max(const rb_fdset_t *f)
const fd_set *p = f->fdset;

RBIMPL_ASSERT_OR_ASSUME(p);
return p->fd_count;
return RBIMPL_CAST((int)p->fd_count);
}

#endif /* RBIMPL_INTERN_SELECT_WIN32_H */

0 comments on commit 2f88a92

Please sign in to comment.