Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Jan 11, 2018

  • removed unnecessary value arguments.
  • removed unnecessary copy initialization.
  • removed unnecessary for range copy.

* removed unnecessary value arguments.
* removed unnecessary copy initialization.
* removed unnecessary for range copy.
@ghost
Copy link
Author

ghost commented Jan 11, 2018

I ran the tests with make check as well as the functional tests via test/functional/test_runner.py

Everything seems fine to me.

Let me know if this is acceptable or whether there's something I missed.

Regards,

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Seems like a good change but probably won't be able to be merged soon given upcoming release & feature freeze.

@@ -103,7 +103,7 @@ UniValue getnetworkhashps(const JSONRPCRequest& request)
return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1);
}

UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
UniValue generateBlocks(const std::shared_ptr<CReserveScript>& coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably more natural to just pass const CReserveScript* than a const shared_ptr.

Copy link
Author

Choose a reason for hiding this comment

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

will do that

@ghost
Copy link
Author

ghost commented Jan 11, 2018

No problem, I can just rebase it when the next merge window happens.

@promag
Copy link
Contributor

promag commented Feb 3, 2018

NACK as is. Too much scattered and different type of changes.

@practicalswift
Copy link
Contributor

@kekimusmaximus Did you use a static analyzer to identify these? Are the fixes exhaustive (covering all instances in the code base)?

@ghost
Copy link
Author

ghost commented Feb 8, 2018

@practicalswift Yes, I'm using an unusual setup, since I created a compile command database.

But at the crux of it it's
http://clang.llvm.org/extra/clang-tidy/index.html

On a more general note, what could be done is have a configure option that has a compilation dry run, where the compiler is set to clang-tidy.

It would also be useful to have maybe a list of agreed upon checks and committed to the repo.
Ideally you'd have the CI run that also.

I could probably create a pull request for that, but at the end of the day the issues still need to be fixed.

@ghost
Copy link
Author

ghost commented Feb 8, 2018

Yes fixes are exhaustive

@practicalswift
Copy link
Contributor

practicalswift commented Feb 8, 2018

@kekimusmaximus Very nice! Did you create the compile command database using Bear (Build EAR)?

One way to increase the chance of getting this kind of changes accepted is to allow for other to recreate the process you used to identify the issues. That will allow others to verify that the changes are correct and exhaustive. Ideally that would include the commands used (including building the compile database) and the relevant output printed (say posted to a gist linked from here).

@ghost
Copy link
Author

ghost commented Feb 8, 2018

@practicalswift Yes I used Bear with verbose make output.

Bear doesn't work with bitcoin by default since the buildsystem makes use of libtool. Given I'm a CMake guy, I couldn't figure out how to get around that so what I did was I hacked Bear.

Basically I added the following line to /usr//bin/bear.

250 re.compile(r'^libtool: compile : clang(++)?(-\d+(.\d+){0,2})?$'),

And of course ran ./configure with CC="clang"
And bear make V=1

Hope that helps. Ideally this would be integrated in the buildsystem, CMake already provides support for compilation databases.

I also tried to just pass CC=clang-tidy at configure time but that fails since IIRC in univalue the configure step tries to compile something to see if there's support and that messes everything up. Again CMake guy.

@ghost
Copy link
Author

ghost commented Feb 8, 2018

What I also need to point out if you're going to try this, since there's classes of checks that can be automatically fixed if you pass fix.

It's not that straight forward, so you need to evaluate the fixes by hand. Sometimes the suggested fixes are wrong for different reasons, I would say 90% of the time is ok except when it's not :)

@laanwj
Copy link
Member

laanwj commented Mar 29, 2018

All in all, the changes in this PR make sense. Avoiding copies is good.
But due to the large number of changes it's very hard to review (as @promag says).
It would make sense to split commits, or maybe even separate PRs, per category of changes - e.g. those that add std::move, those that add const &, the miscellaneous code style changes etc.

@laanwj
Copy link
Member

laanwj commented Apr 26, 2018

Going to close this as it seems to be inactive, let me know if you want to pick it up again then I'll reopen.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants