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 cppcheck [useInitializationList] warnings #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sc0w
Copy link
Member

@sc0w sc0w commented May 27, 2020

No description provided.

Copy link
Member

@gonosztopi gonosztopi left a comment

Choose a reason for hiding this comment

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

See my comment on #190

@sc0w
Copy link
Member Author

sc0w commented May 29, 2020

I don't understand you, this PR isn't related to #190, please review here this PR.

@gonosztopi
Copy link
Member

In short, the problem is: you're fixing warnings not code.

Some examples:

  • in src/FileLock.h you move the initialization of hd into the initialization list of the constructor. You didn't notice that it was a false positive from cppcheck, because hd is of type HANDLE which actually is a void *. Thus the change doesn't come with any benefit but reduced readability.

  • still staying at src/FileLock.h, there is a #if block starting inside a function and spanning through to the end of the file. That's a really really bad thing and should have been fixed first.

  • in src/IP2Country.cpp you move m_DataBaseName but not m_DataBasePath which has the same type (wxString). I admit it has a more complex initializer, but that can be simplified to allow it going, too.

  • moving POD-types into the initialization list doesn't do any benefit (nor harm, to be honest). I guess the warnings you got for src/webserver/src/WebSocket.cpp are because cppcheck didn't know what uint32 was.

  • and last but not least, I miss the style from your patch. You pick some variables (sometimes seemingly randomly) to move and leave the others. With the exceptions being src/utils/wxCas/src/onlinesig.cpp and the ones where there were only one member to initialize...

If you're already using cppcheck, there are more severe issues in the code.... (just a hint). If I were you I would certainly open a branch and commit there all the changes required by cppcheck, all the changes that were made on the way to fix bugs you encounter meanwhile. And maybe create a configuration file for cppcheck to prevent false positives. And, while we're already at it, use meaningful commit messages, describing what and why you change.

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