Static analysis

Everything about development and the OpenMW source code.
Post Reply
lazydev
Posts: 68
Joined: 16 Dec 2012, 14:03

Static analysis

Post by lazydev » 28 May 2014, 07:29

Just found this acticle on the Internets. It is an advertishment of a Cpp static analyser, with a demonstration on OpenMW source.

I guess it could be interesting for the devs.

Link

User avatar
psi29a
Posts: 4881
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Static analysis

Post by psi29a » 28 May 2014, 08:17

It is nice that did that, but it is a gigantic advertisement for their product. "Buy our product for your C++ team."

Many of these errors can be caught if people used clang/llvm by default.

for me it is dead simple:

Code: Select all

scan-build cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE="Release" -DUSE_SYSTEM_TINYXML=TRUE -DBUILD_WITH_DPKG=TRUE ../openmw

scan-build make -j8 # 8 cores of fun 
It took about 10 minutes to run on my system:
real 9m30.033s
user 66m25.562s
sys 2m39.715s
By comparison, this is normal gcc compile time:
real 3m49.013s
user 26m23.129s
sys 1m23.451s


This will produce a report in /tmp with everything you wanted to know, but didn't want to pay for it. ;)

User avatar
Okulo
Posts: 672
Joined: 05 Feb 2012, 16:11

Re: Static analysis

Post by Okulo » 28 May 2014, 08:24

cppcat wrote:CppCat is a tool to search for bugs in C/C++ programs that comes as a plugin for Microsoft Visual Studio 2010, 2012, 2013
I think Cppcat has a few bugs of its own if it attempts to sell its product. Good luck selling plugins for Windows software to this team.

lazydev
Posts: 68
Joined: 16 Dec 2012, 14:03

Re: Static analysis

Post by lazydev » 28 May 2014, 08:50

Guys, my point was to show that some bugs were already found by someone, not to advertise the tool. Please dont be so agressive :oops:

User avatar
cc9cii
Posts: 511
Joined: 28 Mar 2013, 04:01

Re: Static analysis

Post by cc9cii » 28 May 2014, 09:04

Fair enough, I'll go have a look at those pointed out (I have a feeling that one of them was fixed not so long ago)

User avatar
psi29a
Posts: 4881
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Static analysis

Post by psi29a » 28 May 2014, 09:09

Not aggressive, just stating the facts.

Have a look here at my static analysis done a few months ago, for free.
viewtopic.php?f=6&t=2059&p=23852

Some of those mentioned in his post are in this report, meaning they are still there. ;)

Lazydevs... :P

Here is someone's chance to make commits.

User avatar
cc9cii
Posts: 511
Joined: 28 Mar 2013, 04:01

Re: Static analysis

Post by cc9cii » 28 May 2014, 11:41

Had a quick look. Here is my take on it:

#1 - probably duplicate & no real harm, no action for now since I don't know utf8
#2 - already fixed a few weeks back
#3 - probably no real harm, no action for now since I don't know this code
#4 - not sure if this really needs fixing IMHO
#5 - I'll fix this one (because it is easy ;-) )
#6 - #8 - I'll fix these (even easier :D )
#9 - looks like a recent change, probably meant to be mUpperBodyState != UpperCharState_UnEquipingWeap but I'll leave that for the author to confirm
#10 - #11 - left for the author to confirm
#12 - I'll fix this one

EDIT: I'm awed by the power of marketing - there is even a bug raised for this https://bugs.openmw.org/issues/1355 in addition to three separate forum topics :shock:

User avatar
EmperorArthur
Posts: 33
Joined: 17 May 2014, 07:52

Re: Static analysis

Post by EmperorArthur » 02 Jun 2014, 01:43

Here's a scan-build from latest master (538aa6607ecdb6d105ef994b62f8f29711732a1e).

User avatar
cc9cii
Posts: 511
Joined: 28 Mar 2013, 04:01

Re: Static analysis

Post by cc9cii » 02 Jun 2014, 04:03

Hmm... a few div by zero and null ptr ones. Will have to check them out.

Post Reply