-
Notifications
You must be signed in to change notification settings - Fork 17
Various IO-related bug fixes #46
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
Luap99
left a comment
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.
As reference for myself and others
Note that the C errno value may be non-zero, and thus the err result may be non-nil, even if the function call is successful. Unlike normal Go conventions, you should first check whether the call succeeded before checking the error result. For example:
So this seems correct here overall.
| defer func() { d.err = nil }() | ||
| return total, d.err |
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.
Maybe it is just me and I know this is pre existing. But it is not obvious to me that this does work and return the error and at the same time set it to nil for *Data. I had to write a small test to confirm https://go.dev/play/p/9uC2vjLa_NU
Maybe it would be easier on reader to turn this into
err := d.err
d.err =nil
return total, err
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’d slightly prefer the non-defer version as well, but I’ll let the package maintainer decide.
The function is not documented to, and does not, set it. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
The function is not documented to, and does not, set it. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... per the primary return value. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Short writes are a valid outcome of gpgme_data_write, but invalid for io.Writer. Loop to conform to the interface. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
|
Thanks @mtrmac - I don't think changing the defer is enough to warrant another round. So I'll merge as-is. |
errnoin calls that don’t set iterrno, inspect it only when it is known to be validio.Writer.Partially addresses #45 .