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: Move close function in condition body #24277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mi4r
Copy link

@mi4r mi4r commented Oct 15, 2024

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?

   None

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>
Copy link
Contributor

openshift-ci bot commented Oct 15, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mi4r
Once this PR has been reviewed and has the lgtm label, please assign mheon for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Oct 15, 2024
Copy link

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

@mi4r mi4r changed the title api: Replace close function in condition body api: Move close function in condition body Oct 15, 2024
@baude baude added the No New Tests Allow PR to proceed without adding regression tests label Oct 15, 2024
@baude
Copy link
Member

baude commented Oct 15, 2024

approved not having tests

@baude
Copy link
Member

baude commented Oct 15, 2024

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.

@mheon @Luap99 wdyt

Copy link
Member

@Luap99 Luap99 left a 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.

@mheon
Copy link
Member

mheon commented Oct 15, 2024

I don't think there's value in logging the error from close. Maybe do an explicit _ = xyz.Close() so it's clear we are actually ignoring it.

@Luap99
Copy link
Member

Luap99 commented Oct 15, 2024

I don't think there's value in logging the error from close. Maybe do an explicit _ = xyz.Close() so it's clear we are actually ignoring it.

Read the close() man page, there absolute is a reason to check for errors (even when super unlikely)

A careful programmer will check the return value of close(), since it is quite possible that errors on a previous write(2) operation are reported only on the final close() that releases the open file description. Failing to
check the return value when closing a file may lead to silent loss of data. This can especially be observed with NFS and with disk quota.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Change to remote API; merits scrutiny No New Tests Allow PR to proceed without adding regression tests release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants