-
Notifications
You must be signed in to change notification settings - Fork 899
WriteStream: use libgit2's error when we fail to write to the next stream #1107
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
Conversation
@@ -53,9 +53,10 @@ public override void Write(byte[] buffer, int offset, int count) | |||
{ | |||
fixed (byte* bufferPtr = &buffer[offset]) | |||
{ | |||
if (nextStream.write(nextPtr, (IntPtr)bufferPtr, (UIntPtr)count) < 0) | |||
int ret = nextStream.write(nextPtr, (IntPtr)bufferPtr, (UIntPtr)count); | |||
if (ret < 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.
Is write
ever expected to return a positive number? If not, we can skip this check here.
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.
Or use Ensure.Int32Result(ret)
.
And FWIW, we typically use res
rather than ret
.
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.
Ah yes, I'd missed that, that's the function we should use.
Does it matter if we check |
It shouldn't particularly matter whether we do it inside or not, all it's doing is askiing the GC not to move something to which the caller has a reference, so it shouldn't be touching it; but it does seem good form to keep the fixed block to be as small as possible. |
3c88b78
to
ce5db5e
Compare
@@ -51,14 +51,14 @@ public override void Write(byte[] buffer, int offset, int count) | |||
{ | |||
unsafe | |||
{ | |||
int res; |
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.
Have to define this outside the unsafe
ce5db5e
to
a6dccd1
Compare
👍 assuming we're green |
👍 |
WriteStream: use libgit2's error when we fail to write to the next stream
👍 |
This should let us see what libgit2 thinks the problem is when we fail to pass the data forward.
#1030 (comment)