aliens

Author Topic: Static code analysis  (Read 5155 times)

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Static code analysis
« 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.


Offline karadoc

  • Colonel
  • ****
  • Posts: 232
    • View Profile
Re: Static code analysis
« Reply #1 on: September 04, 2016, 08:45:02 am »
The link asks for a user-name and password. Is this expected?

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Static code analysis
« Reply #2 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.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Static code analysis
« Reply #3 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

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Static code analysis
« Reply #4 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.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Static code analysis
« Reply #5 on: September 04, 2016, 03:33:15 pm »
Meridian is based on my repo, and this error is from my code :)