-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix FileDescriptor#pos
return Int64
on armv6
#10845
Fix FileDescriptor#pos
return Int64
on armv6
#10845
Conversation
bd5f584
to
1509694
Compare
@@ -80,7 +80,7 @@ module Crystal::System::FileDescriptor | |||
end | |||
|
|||
private def system_pos | |||
pos = LibC.lseek(fd, 0, IO::Seek::Current) | |||
pos = LibC.lseek(fd, 0, IO::Seek::Current).to_i64! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it need to_i64!
if to_i64
already introduces no additional runtime checks for types <= 64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accociate the exclamation mark method when I know the cast is safe and doesn't need any check. But we can use #to_i64
as well. I'm not sure I care either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We happen to live in a world where we can say that this will never be Int128
. But why rely on that instead of just writing the expression that's always correct? I think those !
methods need a high bar for acceptance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, on the other hand maybe even if it was Int128
we'd prefer to assume that there are never such huge files. Whatever :D
@@ -13,7 +13,7 @@ class File::PReader < IO | |||
@pos = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related, but pos
really should be Int64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it anyways. It's in a similar mood.
FileDescriptor#pos
return Int64
on armv6
Since #10580, the return type of
IO::FileDescriptor#pos
is restricted toInt64
. This means it's actually broken on armv6.Similarly,
IO::FileDescriptor#pread
was missing a type restriction and returned different types depending on the target platform. This is getting unified.This resolves the initial reports of #10645, but there may be more (#10645 (comment)).