This forum has been archived. All content is frozen. Please use KDE Discuss instead.

A few issues found by cppcheck.

Tags: None
(comma "," separated)
ibram
Registered Member
Posts
1
Karma
0

A few issues found by cppcheck.

Wed Apr 30, 2014 10:27 pm
Hi all. Decided to make a little contribution to this great project. Got src from git repos and feed it to cppcheck. Let me introduce the found mistakes. Sorry if some them are fake - I don't participate in kdenlive development and don't know it's source and work system.
Used cmd: cppcheck --enable=all path_to_kdenlive_src_folder
  • src/kthumb.cpp
    Code: Select all
        return image.rgbSwapped();
        if (!image.isNull()) {
            if (ow > (2 * displayWidth)) {
                // there was a scaling problem, do it manually
                image = image.scaled(displayWidth, height).rgbSwapped();
            } else {
                image = image.scaled(displayWidth, height, Qt::IgnoreAspectRatio).rgbSwapped();
            }
            p.fill(QColor(100, 100, 100, 70));
            QPainter painter(&p);
            painter.drawImage(p.rect(), image);
            painter.end();
        } else
            p.fill(QColor(Qt::red).rgb());
        return p;
  • src/mltdevicecapture.cpp
    Code: Select all
    if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
        kDebug()<<"// STOP 6";
        delete m_mltConsumer;
        delete m_mltProducer;
       
        m_mltProducer = NULL;
        m_mltConsumer = NULL;
        //delete m_mltConsumer;
        return; // BLOCKS THE CODE BELOW
        /*if (m_showFrameEvent) delete m_showFrameEvent;
        m_showFrameEvent = NULL;
        if (m_consumerThreadStartedEvent) delete m_consumerThreadStartedEvent;
        m_consumerThreadStartedEvent = NULL;
        if (m_consumerThreadStoppedEvent) delete m_consumerThreadStoppedEvent;
        m_consumerThreadStoppedEvent = NULL;*/
       

        if (m_mltProducer) {
            QList <Mlt::Producer *> prods;
            Mlt::Service service(m_mltProducer->parent().get_service());

    As we can see the whole block code will never be executed. There is a return statement which blocks the code below it.
  • Memory leak src/lib/external/kiss_fft/tools/kiss_fastfir.c
    Code: Select all
     kffsamp_t * h;
        // ...
        h = (kffsamp_t*)malloc(sizeof(kffsamp_t)*nh);
        // ...
        return 0;

    Forget to free the memory?
  • src/lib/external/kiss_fft/tools/psdpng.c
    Memory leak with vals and row_pointers variables.

You can see below full list of interesting messages from cppcheck:
[src/renderer.h:58] -> [src/definitions.h:83]: (style) Variable 'Playlist' hides enumerator with same name
[src/kthumb.cpp:237]: (style) Statements following return, break, continue, goto or throw will never be executed
[src/lib/external/kiss_fft/tools/kiss_fastfir.c:81]: (style) Checking if unsigned variable 'nfft' is less than zero.
[src/lib/external/kiss_fft/tools/kiss_fastfir.c:467]: (error) Memory leak: h
[src/lib/external/kiss_fft/tools/kiss_fastfir.c:288]: (style) Checking if unsigned variable 'nread' is less than zero.
[src/lib/external/kiss_fft/tools/kiss_fastfir.c]: (information) Interrupted checking because of too many #ifdef configurations.
[src/lib/external/kiss_fft/tools/psdpng.c:173]: (error) Common realloc mistake: 'vals' nulled but not freed upon failure
[src/lib/external/kiss_fft/tools/psdpng.c:210]: (error) Common realloc mistake: 'row_pointers' nulled but not freed upon failure
[src/mltdevicecapture.cpp:218]: (style) Statements following return, break, continue, goto or throw will never be executed
[src/mltdevicecapture.cpp:535]: (style) Statements following return, break, continue, goto or throw will never be executed
[src/scopes/audioscopes/spectrogram.cpp:393]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[src/scopes/audioscopes/spectrogram.cpp:433]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[src/v4l/v4lcapture.cpp:67]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses
[src/widgets/kis_curve_widget.cpp:457]: (style) Clarify calculation precedence for - and ?
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS

Re: A few issues found by cppcheck.

Wed Apr 30, 2014 10:31 pm
Hi!

The best way to deal with such issues is to just fix them if they are indeed wrong, and submit a patch to reviewboard.kde.org.

Thanks!
Greetings,
Sven


I'm working on the KDevelop IDE.


Bookmarks



Who is online

Registered users: Bing [Bot], gfielding, Google [Bot], Sogou [Bot]