OpenXcom Forum

Contributions => Programming => Topic started by: Stoddard on September 04, 2016, 03:15:50 am

Title: Static code analysis
Post by: Stoddard on September 04, 2016, 03:15:50 am
Results are at https://lxnt.wtf/sca/

oxc- means SupSuper's repo
oxem- means Meridian's repo

clang is clang-llvm scan-build tool

callcatcher reports methods that aren't called

cppcheck is older and cargo-culty, and doesn't  add much substantial info.

Some of the result are false positives, the tools have their limitations.

Basically I want to assign 9th mouse button to drag-scroll and can't, since SDL1.2' s SDL_GetMouseState() is limited to 8, so it's either move to SDL2 or reimplement SDL_GetMouseState() to support more that 8.

I went with the latter, but still was very frustrated refactoring code only to discover that it was sitting unused for like 3 years already, and that was very time consuming.

To cut down on work, dead code should be eliminated. Callcatcher helps with this. Clang shows mostly non-obvious call graph paths that might result in a crash, this might help in pinning down if someone reports one.

Title: Re: Static code analysis
Post by: karadoc on September 04, 2016, 08:45:02 am
The link asks for a user-name and password. Is this expected?
Title: Re: Static code analysis
Post by: Stoddard on September 04, 2016, 11:52:18 am
The link asks for a user-name and password. Is this expected?

Oh shi... I'm sorry, forgot about that. Now it shouldn't.
Title: Re: Static code analysis
Post by: Yankes on September 04, 2016, 01:52:31 pm
Stoddard you can cherry-pick this commit: https://github.com/Yankes/OpenXcom/commit/cb0929dc4f6e35c224fdbbb14411773d7983c320 to fix error in clang
Title: Re: Static code analysis
Post by: Stoddard on September 04, 2016, 03:27:04 pm
Stoddard you can cherry-pick this commit: https://github.com/Yankes/OpenXcom/commit/cb0929dc4f6e35c224fdbbb14411773d7983c320 to fix error in clang

Well thank you, but I don't exaclty have anything to cherry-pick it to.  The results above are for SupSuper's and Meridian's repos. I can add yours there too if you wish.
Title: Re: Static code analysis
Post by: Yankes on September 04, 2016, 03:33:15 pm
Meridian is based on my repo, and this error is from my code :)