Back to success stories

Sample of Defect

Project Name CID Checker Category Developer Description
wxMathplot 50070 COPY_PASTE_ERROR Incorrect expression Without coverity i probably would not have found this copy&paste error. Thanks for this checker. The impact of this issue would be a wrong positioned text message on the screen. This would have distracted/irritated the user.
File: /mathplot.cpp
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
        m_maxX  = 1;
        m_minY  = -1;
        m_maxY  = 1;
    }
}

//-----------------------------------------------------------------------------
// mpText - provided by Val Greene
//-----------------------------------------------------------------------------

IMPLEMENT_DYNAMIC_CLASS(mpText, mpLayer)


/** @param name text to be displayed
@param offsetx x position in percentage (0-100)
@param offsetx y position in percentage (0-100)
*/
mpText::mpText( wxString name, int offsetx, int offsety )
{
    SetName(name);

    if (offsetx >= 0 && offsetx <= 100)
        m_offsetx = offsetx;
    else
 << "this->m_offsetx" looks like the original copy.
2487
2488
2489
2490
2491
        m_offsetx = 5;

    if (offsety >= 0 && offsety <= 100)
        m_offsety = offsety;
    else
 <<< CID 50070: Incorrect expression COPY_PASTE_ERROR
 <<< "m_offsetx" in "this->m_offsetx" looks like a copy-paste error.
 < Should it say "m_offsety" instead?
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
        m_offsetx = 50;
    m_type = mpLAYER_INFO;
}

/** mpText Layer plot handler.
This implementation will plot the text adjusted to the visible area.
*/

void mpText::Plot(wxDC & dc, mpWindow & w)
{
        if (m_visible) {
                dc.SetPen(m_pen);
                dc.SetFont(m_font);

                wxCoord tw=0, th=0;
                dc.GetTextExtent( GetName(), &tw, &th);

        //     int left = -dc.LogicalToDeviceX(0);
        //     int width = dc.LogicalToDeviceX(0) - left;
        //     int bottom = dc.LogicalToDeviceY(0);
        //     int height = bottom - -dc.LogicalToDeviceY(0);

        /*    dc.DrawText( GetName(),
                (int)((((float)width/100.0) * m_offsety) + left - (tw/2)),
                (int)((((float)height/100.0) * m_offsetx) - bottom) );*/
                int px = m_offsetx*(w.GetScrX() - w.GetMarginLeft() - w.GetMarginRight())/100;
                int py = m_offsety*(w.GetScrY() - w.GetMarginTop() - w.GetMarginBottom())/100;
Events:
original mathplot.cpp:2487
remediation mathplot.cpp:2492
copy_paste_error mathplot.cpp:2492