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 mutex passed by value warning #57

Merged
merged 1 commit into from
Sep 1, 2021
Merged

Conversation

jeffreylovitz
Copy link
Contributor

@jeffreylovitz jeffreylovitz commented Sep 1, 2021

Since the Graph struct contains a mutex, misbehaviors can occur if this struct is copied by pass-by-value returns. GraphNew instantiates and returns a Graph value, but this is safe because no other copies of the object exist.

The DeepSource complaint can be simply avoided by returning the new Graph struct directly rather than assigning it to a local variable first.

@swilly22 swilly22 merged commit d223574 into master Sep 1, 2021
@swilly22 swilly22 deleted the mutex-passed-by-value branch September 1, 2021 17:33
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.

2 participants