Menu

False Positive (V2.1)

2020-07-22
2020-07-22
  • Arseniy Masyuk

    Arseniy Masyuk - 2020-07-22

    Hello,

    I think there is a false positive message:

    CWE: 571
    Condition 'alpha>=1' is always true

    on the following code:

    i2d::CVector2d CLine2d::GetNearestPoint(const i2d::CVector2d& point) const
    {
    double alpha = GetCastAlpha(point);

    if (alpha <= 0){
    return m_point1;
    }
    else if (alpha >= 1){
    return m_point2;
    }
    else{
    return GetPositionFromAlpha(alpha);
    }
    }

    Because alpha can be between 0 and 1 as well.

    PS: thank you for the great software!

     
  • Daniel Marjamäki

    Thanks! I created ticket https://trac.cppcheck.net/ticket/9817

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.