Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Disambiguity of all the implemented locks #4045

Conversation

thsfs
Copy link
Contributor

@thsfs thsfs commented Jan 13, 2023

Found a warning when building the node for Windows.

...
warning C4930: 'std::unique_lock<nano::mutex> lock(nano::mutex)': prototyped function not called (was a variable definition intended?)
...

This is related to an ambiguity described by the wiki, where the C++ compiler tries to declare a function as lock instead of creating an object for it.

The best approach is to use the uniform initialization {} when there is any argument. The warning was issued only for vote_processor.cpp, but decided to change all the mutex lock object creations.

Thiago Silva added 30 commits January 13, 2023 10:48
@thsfs thsfs requested a review from clemahieu January 13, 2023 16:52
@thsfs thsfs modified the milestones: V24.0, V25.0 Jan 13, 2023
@dsiganos
Copy link
Contributor

I find it annoying that our formatter treat {} differently from ().
It remove a space before { and adds spaces inside the brackets.

-                       nano::lock_guard<nano::mutex> lk (connections_mutex);
+                       nano::lock_guard<nano::mutex> lk{ connections_mutex };

@thsfs
Copy link
Contributor Author

thsfs commented Jan 13, 2023

I find it annoying that our formatter treat {} differently from (). It remove a space before { and adds spaces inside the brackets.

-                       nano::lock_guard<nano::mutex> lk (connections_mutex);
+                       nano::lock_guard<nano::mutex> lk{ connections_mutex };

Yes, but in another perspective it is easier to spot the difference.

@thsfs thsfs merged commit 7a052d4 into nanocurrency:develop Jan 13, 2023
@thsfs thsfs deleted the object-creation-funcion-declaration-ambiguity-fix branch January 13, 2023 18:02
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants