Skip to content
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: Remove double close in ImportImages #24269

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mi4r
Copy link

@mi4r mi4r commented Oct 15, 2024

tmpfile is closed using defer. Remove explicit closing.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Does this PR introduce a user-facing change?

   None

tmpfile is closed using defer. Remove explicit closing.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Tigran Sogomonian <[email protected]>
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Oct 15, 2024
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

openshift-ci bot commented Oct 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mi4r, vrothberg

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 15, 2024
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

1 similar comment
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@@ -410,7 +410,6 @@ func ImagesImport(w http.ResponseWriter, r *http.Request) {
return
}

tmpfile.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the current code is not doing this correct either but I think there is a real reason to call close here and not via defer close(). close() can return real write errors so it likely is best to ensure the file is closed and we check that there was no error before passing that to file path to import.

One close is returned to its place, the second one is replaced
in the body of the error condition.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Тигран Согомонян <[email protected]>
@mi4r
Copy link
Author

mi4r commented Oct 15, 2024

There were accidently added changes

@mi4r
Copy link
Author

mi4r commented Oct 15, 2024

I will form new clean merge request

@mi4r
Copy link
Author

mi4r commented Oct 15, 2024

#24277

@baude
Copy link
Member

baude commented Oct 15, 2024

please see my comments in #24277

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Change to remote API; merits scrutiny release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants