Skip to content

Disambiguity of all the implemented locks#4045

Merged
thsfs merged 40 commits intonanocurrency:developfrom
thsfs:object-creation-funcion-declaration-ambiguity-fix
Jan 13, 2023
Merged

Disambiguity of all the implemented locks#4045
thsfs merged 40 commits intonanocurrency:developfrom
thsfs:object-creation-funcion-declaration-ambiguity-fix

Conversation

@thsfs
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants