Opened 5 years ago

Last modified 5 years ago

#5599 new defect

Fix some Major CppCheck warnings

Reported by: Stan Owned by:
Priority: Should Have Milestone: Backlog
Component: Core engine Keywords:
Cc: Krinkle Patch:

Description

int munmap(void* start, size_t UNUSED(len))
{
    // UnmapViewOfFile checks if start was returned by MapViewOfFile*;
    // if not, it will fail.
    BOOL ok = UnmapViewOfFile(start);
    if(!ok)
        // VirtualFree requires dwSize to be 0 (entire region is released).
       ok = VirtualFree(start, 0, MEM_RELEASE);

    WARN_IF_FALSE(ok);
    return ok? 0 : -1;
}
    // we have to return a pointer to sem_t, and the sem_init interface
    // requires sem_t to be usable as the handle, so we'll have to
    // allocate memory here (ugh).
    sem_t* sem = new sem_t;
    *sem = (sem_t)hSemaphore;
   return sem;
    // (instead of counting the total string size, just use the
    // SMBIOS size - typically 1-2 KB - as an upper bound.)
   stringStoragePos = stringStorage = (char*)calloc(table.size(), sizeof(char));   // freed in Cleanup

    if(!stringStorage)
        WARN_RETURN(ERR::NO_MEM);
  • Uninitialized struct member: frame.timeStart
  • https://cwe.mitre.org/data/definitions/628.html
  • source/ps/Profiler2GPU.cpp@183
  • source/ps/Profiler2GPU.cpp@330
  • source/ps/Profiler2GPU.cpp@531
            }
            else
            {
                // Reuse the previous frame's sync data
                frame.syncTimeStart = m_Frames[m_Frames.size()-1].syncTimeStart;
                frame.syncTimestampStart = m_Frames[m_Frames.size()-1].syncTimestampStart;
            }
           m_Frames.push_back(frame);
    ...
        void FrameStart()
    
        {
    
            ProcessFrames();
            SFrame frame;
            frame.num = m_Profiler.GetFrameNumber();
            frame.timeStart = m_Profiler.GetTime();
           m_Frames.push_back(frame);
    
    ...
    
        void FrameStart()
    
        {
    
            ProcessFrames();
            SFrame frame;
            frame.num = m_Profiler.GetFrameNumber();
            frame.timeStart = m_Profiler.GetTime();
           m_Frames.push_back(frame);
    
  • Uninitialized struct member: obj.owner
  • https://cwe.mitre.org/data/definitions/908.html
  • source/.../atlas/GameInterface/Handlers/ObjectHandlers.cpp@1042
            CmpPtr<ICmpPosition> cmpPosition(sim, obj.entityID);
            if (cmpPosition)
            {
                obj.pos = cmpPosition->GetPosition();
                obj.rot = cmpPosition->GetRotation();
            }

            oldObjects.push_back(obj);

Attachments (1)

cppcheck-result.7z (84.8 KB ) - added by Stan 5 years ago.
File obtained by running cppcheck 1.88 with the following flags --xml-version=2 --language=c++ --std=c++11 --max-ctu-depth=16 --enable=all --quiet --xml

Download all attachments as: .zip

Change History (2)

by Stan, 5 years ago

Attachment: cppcheck-result.7z added

File obtained by running cppcheck 1.88 with the following flags --xml-version=2 --language=c++ --std=c++11 --max-ctu-depth=16 --enable=all --quiet --xml

comment:1 by Krinkle, 5 years ago

Cc: Krinkle added
Note: See TracTickets for help on using tickets.