Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

b2DistanceJoint::Draw initializes length variable but never uses it #694

Closed
cugone opened this issue Sep 2, 2021 · 0 comments · Fixed by #709
Closed

b2DistanceJoint::Draw initializes length variable but never uses it #694

cugone opened this issue Sep 2, 2021 · 0 comments · Fixed by #709

Comments

@cugone
Copy link

cugone commented Sep 2, 2021

I compile all projects in Warning Level 4 with treat warnings as errors turned on. The following function returns a warning as an error where the variable length is initialized but never used.

void b2DistanceJoint::Draw(b2Draw* draw) const
{
        const b2Transform& xfA = m_bodyA->GetTransform();
        const b2Transform& xfB = m_bodyB->GetTransform();
        b2Vec2 pA = b2Mul(xfA, m_localAnchorA);
        b2Vec2 pB = b2Mul(xfB, m_localAnchorB);

        b2Vec2 axis = pB - pA;

        //`length` variable is initialized but never used!
        float length = axis.Normalize();

        b2Color c1(0.7f, 0.7f, 0.7f);
        b2Color c2(0.3f, 0.9f, 0.3f);
        b2Color c3(0.9f, 0.3f, 0.3f);
        b2Color c4(0.4f, 0.4f, 0.4f);

        draw->DrawSegment(pA, pB, c4);
        
        b2Vec2 pRest = pA + m_length * axis;
        draw->DrawPoint(pRest, 8.0f, c1);

        if (m_minLength != m_maxLength)
        {
                if (m_minLength > b2_linearSlop)
                {
                        b2Vec2 pMin = pA + m_minLength * axis;
                        draw->DrawPoint(pMin, 4.0f, c2);
                }

                if (m_maxLength < FLT_MAX)
                {
                        b2Vec2 pMax = pA + m_maxLength * axis;
                        draw->DrawPoint(pMax, 4.0f, c3);
                }
        }
}
erincatto added a commit that referenced this issue Dec 31, 2021
@erincatto erincatto mentioned this issue Dec 31, 2021
@erincatto erincatto linked a pull request Dec 31, 2021 that will close this issue
erincatto added a commit that referenced this issue Dec 31, 2021
Small fixes for: #681, #686, #689, #690, #691, #692, #694, #695, #696
Fix workflow for main
brianwinterpixel pushed a commit to winterpixelgames/box2d that referenced this issue Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant