Menu

Custom Config File & CPPCheck GUI

2016-09-08
2016-09-13
  • Jocris Bitoon

    Jocris Bitoon - 2016-09-08

    Hello,

    I am trying to explore the possibility of extending the CPPCheck functionality for our code. Our code is in C and implements an embedded software. I actually have 2 questions:

    1) I am trying to load a custom config file using the CPPCheck GUI using View -> Library Editor. My custom config file has this:

    <def> <memory> <alloc>mm_malloc</alloc> <dealloc>mm_free</dealloc> </memory> </def>

    When I try loading it, I see no change in the Library Editor window. Can I trust that I have been able to load the config file? How do I load a custom configuration file via the CPPCheck GUI?

    2) My goal with my custom config file is to tell CPPCheck to check the calls for mm_malloc and mm_free and identify possible memory leak. Please note that mm_malloc does not call malloc() and mm_free does not call free() function of C. Our code manages our own memory. Is it possible to make CPPCheck do that?

     

    Last edit: Jocris Bitoon 2016-09-08
  • Daniel Marjamäki

    hello! sorry for late reply.

    1) In the GUI, create a project. Put the cfg file in the same folder as the cppcheck project file. Now, in the project dialog in the GUI, you should see a checkbox where you can enable the cfg file.

    2) yes your configuration should fix that.

    If you put these 3 files in a empty folder:

    1.cfg:

    <def> <memory> <alloc>mm_malloc</alloc> <dealloc>mm_free</dealloc> </memory> </def>
    

    1.c:

    void f() {
        void *p = mm_malloc(10);
        /* forgot mm_free */
    }
    

    1.cppcheck:

    <?xml version="1.0" encoding="UTF-8"?>
    <project version="1">
        <libraries>
            <library>1</library>
        </libraries>
    </project>
    

    Then when you check "1.cppcheck" in the GUI you will see the memory leak.

     

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.