-
Notifications
You must be signed in to change notification settings - Fork 2.7k
api: Move close function in condition body #24277
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
api: Move close function in condition body #24277
Conversation
The close is replaced in the body of the error condition. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Tigran Sogomonian <tsogomonian@astralinux.ru>
Ephemeral COPR build failed. @containers/packit-build please check. |
approved not having tests |
in looking at this PR, I saw the the error is not handled or logged. Then looking at just this file more broadly, sometimes it is and sometimes not. Some are deferred. If we have a consensus on how these should handled in the whole file, I would prefer that. I did not look close enough to verify that this is a possibility. |
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 suggested this but it only makes sense if the error on tmpfile.Close() above source = tmpfile.Name()
is checked and so that there was no errors during write.
Using defer in this context is not helpful because we want the tmpfile to be closed before we pass the file path to the import API.
I don't think there's value in logging the error from close. Maybe do an explicit |
Read the close() man page, there absolute is a reason to check for errors (even when super unlikely)
I know we ignore this pretty much elsewhere but here we are actually writing something potential large that my increase the odds of hitting such cases. |
This PR has been marked for 5.3 inclusion but it must be merged prior to Nov 5 for inclusion in 5.3 RC3. PRs not merged by that date are considered on a case by case basis for backporting. |
Once again I would like to clarify what needs to be done. Do you want me to add if err = tmpfile.Close(); err != nill {log} or do you want me to fix this everywhere in the file, or would it be better to make this a separate pr and then accept this one without processing this error? |
I would want this
ignoring the close error on the copy error path is fine but on the good path we should make sure we closed the file successfully to avoid io errors |
Add error check during tmpfile close. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Tigran Sogomonian <tsogomonian@astralinux.ru>
LGTM |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mi4r, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks @mi4r |
The close is moved in the body of the error condition.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Does this PR introduce a user-facing change?