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

Fix useless error check in extractTarGz #1528

Merged
merged 1 commit into from
May 14, 2024

Conversation

alexandear
Copy link
Contributor

This PR fixes impossible condition nil != nil.

Consider the following code:

f, err := os.Create(path)
if err != nil {
	return err
}

f.Chmod(info.Mode())
if err != nil {
	return err
}

The second if err != nil effectively becomes if nil != nil due to the preceding if err != nil check.

There are two ways to fix this: the first is to simply delete the second if err != nil, and the second is to handle an error from f.Chmod, which is the option I have chosen.

Copy link
Member

@bentranter bentranter left a comment

Choose a reason for hiding this comment

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

Great find @alexandear, thank you!

@bentranter bentranter merged commit d5ed40c into digitalocean:main May 14, 2024
7 checks passed
@alexandear alexandear deleted the fix/useless-err-check branch May 14, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants