[Bf-committers] PVS-Studio Static Analysis

Jason Wilkins jason.a.wilkins at gmail.com
Wed Apr 25 03:23:34 CEST 2012


The "Uncreated file" is a false alarm.  The value of file_ is
initialized by another member function.  Probably not the most clear
way to write the code, but not an error.  I already contacted viva64
to suggest they tighten up that part of their analysis.

On Tue, Apr 24, 2012 at 8:15 PM, Jason Wilkins
<jason.a.wilkins at gmail.com> wrote:
> Oh, the way it is written now is confusing I think, since it does
> several no-ops.
>
> Wouldn't UINT_MAX be better?
>
> On Tue, Apr 24, 2012 at 8:11 PM, Erwin Coumans <erwin.coumans at gmail.com> wrote:
>> You are looking at the code that I fixed yesterday, see my commit message
>> for details here:
>> http://lists.blender.org/pipermail/bf-blender-cvs/2012-April/045090.html
>>
>>
>>>>V610 Undefined behavior. Check the shift operator '<<. The left operand
>> '(~0)' is negative. extern_bullet btquantizedbvh.h 82
>>
>> ~(0) is signed -1, negative, while ~(x&0) is positive unsigned, so it fixes
>> the undefined behavior.
>> Thanks,
>> Erwin
>>
>>
>>
>> On 24 April 2012 18:01, Jason Wilkins <jason.a.wilkins at gmail.com> wrote:
>>
>>> This line in btQuantizedBvh.h confuses me:
>>>
>>> int     getTriangleIndex() const
>>>        {
>>>                btAssert(isLeafNode());
>>>                unsigned int x=0;
>>>                unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);
>>>                // Get only the lower bits where the triangle index is
>>> stored
>>>                return (m_escapeIndexOrTriangleIndex&~(y));
>>>        }
>>>
>>> Ostensibly the error is that ~0 is -1 (unsigned) and shifting an
>>> unsigned is undefined or unspecified (forget which).
>>>
>>> But I'm actually confused why this code is written this way.
>>> x=0, then x&0 == 0, even if x wasn't 0.
>>>
>>> Only after that do we get to the undefined behavior.
>>>
>>> I guess I could puzzle through it, but somebody else might just know :-)
>>>
>>> On Tue, Apr 24, 2012 at 7:30 PM, Jason Wilkins
>>> <jason.a.wilkins at gmail.com> wrote:
>>> > I'm working through them and fixing what Clang did not catch.
>>> >
>>> > I was going to say the same thing as Nicholas, code analysis is such a
>>> > wide open field with virtually infinite number of things you can check
>>> > for, that having more than one tool is a good idea.
>>> >
>>> > On Tue, Apr 24, 2012 at 6:30 PM, Nicholas Bishop
>>> > <nicholasbishop at gmail.com> wrote:
>>> >> Not necessarily; different static analyzers can detect different types
>>> >> of potential problems. The PVS analysis contains some interesting
>>> >> things like the "Misprint in a homogeneous code block" section that I
>>> >> don't think clang's analyzer does.
>>> >>
>>> >> On Tue, Apr 24, 2012 at 7:20 PM, Tom M <letterrip at gmail.com> wrote:
>>> >>> We have a page with generated CLang static analysis,
>>> >>>
>>> >>> http://clang.blenderheads.org/trunk/
>>> >>>
>>> >>> It probably shows the same bugs as PVS-Studio does.
>>> >>>
>>> >>> LetterRip
>>> >>>
>>> >>> On Tue, Apr 24, 2012 at 4:15 PM, Nicholas Bishop
>>> >>> <nicholasbishop at gmail.com> wrote:
>>> >>>> I think some of these have been fixed already in recent commits from
>>> Campbell.
>>> >>>>
>>> >>>> On Tue, Apr 24, 2012 at 7:11 PM, Jason Wilkins
>>> >>>> <jason.a.wilkins at gmail.com> wrote:
>>> >>>>> http://www.viva64.com/en/b/0145/#ID0EO3BK
>>> >>>>>
>>> >>>>> It appears that Andrey Karpov has done an analysis of Blender source
>>> >>>>> code using his PVS-Studio tool.  He did this just yesterday, so I
>>> >>>>> assume the problems he found are still in the source.  He offers free
>>> >>>>> licenses to open source project members (3500 euro software
>>> otherwise,
>>> >>>>> wow).
>>> >>>>>
>>> >>>>> I was thinking of investigating the problems he found and seeing if I
>>> >>>>> could fix them.
>>> >>>>> _______________________________________________
>>> >>>>> Bf-committers mailing list
>>> >>>>> Bf-committers at blender.org
>>> >>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>> >>>> _______________________________________________
>>> >>>> Bf-committers mailing list
>>> >>>> Bf-committers at blender.org
>>> >>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>> >>> _______________________________________________
>>> >>> Bf-committers mailing list
>>> >>> Bf-committers at blender.org
>>> >>> http://lists.blender.org/mailman/listinfo/bf-committers
>>> >> _______________________________________________
>>> >> Bf-committers mailing list
>>> >> Bf-committers at blender.org
>>> >> http://lists.blender.org/mailman/listinfo/bf-committers
>>> _______________________________________________
>>> Bf-committers mailing list
>>> Bf-committers at blender.org
>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers


More information about the Bf-committers mailing list