#1852 closed defect (fixed)
[PATCH] Checked sourcecode with cppcheck
Reported by: | Mr. X | Owned by: | ben |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Alpha 15 |
Component: | Core engine | Keywords: | patch |
Cc: | Patch: |
Description
I checked the sourcecode of 0ad with cppcheck (current git head) once again (#606). I'll attach the log.
The majority of the message are complaints about uninitialized variables in constructor, variable scopes that can be reduced, about C-style pointer castings and functions that can be made const or static. However, among the "conclusive Messages", there are also 29 performance messages, three errors and lots of warnings. I did not verify that all these messages are correct, so there might be a few false positives.
I attached three log files:
- 0ad_full.txt contains all messages from cppcheck.
- 0ad_conclusive.txt contains all messages flagged as "conclusive"
- 0ad_cleaned.txt contains all conclusive message without the three most often shown messages, to make it easier for you to spot the other ones
Attachments (9)
Change History (27)
by , 11 years ago
Attachment: | 0ad_cleaned.txt added |
---|
by , 11 years ago
Attachment: | 0ad_conclusive.txt added |
---|
by , 11 years ago
Attachment: | 0ad_full.txt added |
---|
comment:1 by , 11 years ago
Milestone: | Backlog → Alpha 13 |
---|
comment:2 by , 11 years ago
Milestone: | Alpha 13 → Backlog |
---|---|
Priority: | Should Have → Nice to Have |
comment:3 by , 11 years ago
by , 11 years ago
Attachment: | catch-exception-by-ref.patch added |
---|
by , 11 years ago
Attachment: | mark-noncopyable-to-prevent-memleak.patch added |
---|
by , 11 years ago
Attachment: | use-stl-empty-not-size.patch added |
---|
by , 11 years ago
Attachment: | wrong-operator-signature.patch added |
---|
by , 11 years ago
Attachment: | memleak-sectionlayout.patch added |
---|
by , 11 years ago
Attachment: | remove-unused.patch added |
---|
comment:4 by , 11 years ago
Keywords: | review patch added |
---|---|
Summary: | Checked sourcecode with cppcheck → [PATCH] Checked sourcecode with cppcheck |
comment:10 by , 11 years ago
Thanks for the patches Markus, I think that leaves only memleak-sectionlayout.patch and remove-unused.patch:
- For the unused variables, we have to be very careful. Sometimes they are hiding logic errors, things were not implemented fully or correctly, or intentionally left as reminders.
- The
SectionLayout
patch causes a crash when closing Atlas.
follow-up: 12 comment:11 by , 11 years ago
The file memleak-sectionlayout.patch can be ignored. Reading more about wxWidgets it seems to somehow free registered child widgets automatically when the parent window is destroyed. So there is practically no memleak.
Regarding remove-unused.patch:
Sometimes there are comments for something not being implemented etc. I then commented it out. The others are removed as leper said it would being pointless to add more commented out code (especially with revision control).
I think unused variables should be removed if not needed, because it normally is a sign for an logical error. (And as such a warning is issued by the compiler.)
comment:12 by , 11 years ago
Cc: | added |
---|
Replying to Markus:
Regarding remove-unused.patch:
Sometimes there are comments for something not being implemented etc. I then commented it out. The others are removed as leper said it would being pointless to add more commented out code (especially with revision control).
I think unused variables should be removed if not needed, because it normally is a sign for an logical error. (And as such a warning is issued by the compiler.)
This is true, but who is going to read the revision log to find random chunks of code that were removed? Or scan the source code looking for commented out variable definitions? At least with compiler warnings there is a chance they will annoy someone enough to properly understand and fix them :)
I'd rather have Yves weigh in on the JS debugger related code, wraitii for the water manager related code. GUItext.cpp
and ComponentManagerSerialization.cpp
I'm not sure about, but those in CCmpAIManager.cpp
and MessagePasserImpl.cpp
can definitely go.
comment:13 by , 11 years ago
Milestone: | Backlog → Alpha 15 |
---|
comment:15 by , 11 years ago
Note: the unused code in TerrainRenderer.cpp
was obviously an unfinished attempt to use POT textures for fancy water rendering, so I added TODOs for both cases where it's using renderer height and width. That should be fixed anyway for efficiency, but it requires a bit of fiddling with the shaders.
All that's left from the patches is the unused vars in the JS debugger, I'd like to get Yves' input on that, whether it's a bug, unfinished feature, or small oversight.
comment:16 by , 11 years ago
Are there any more patches to be reviewed, or have all of these been committed? So far it looks like all changes have been applied and this patch can be closed?
comment:18 by , 10 years ago
Cc: | removed |
---|---|
Keywords: | review removed |
Thanks for the patches.
(Please create a new ticket for any future cppcheck results and associated patches, even if it's tomorrow :))
In 13337: