Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build warning] Various warnings from analysis tools #9

Open
dwatteau opened this issue Nov 14, 2020 · 1 comment
Open

[Build warning] Various warnings from analysis tools #9

dwatteau opened this issue Nov 14, 2020 · 1 comment
Assignees

Comments

@dwatteau
Copy link
Owner

dwatteau commented Nov 14, 2020

Happens when compiling with MSVC 19.27.29112 at /W3 on x64. Clang and GCC don't report them.

ScummFont

src\ScummFont\scummfont.cpp(487) : warning C6283: 'unsigned char * glFontBitmap' is allocated with array new [], but deleted with scalar delete.: Lines: 493, 487

seems legit and simple to fix (EDIT: done).

src\ScummFont\scummfont.cpp(548) : warning C6386: buffer overrun: accessing 'glFontBitmap', the writable size is 'maxWidth*maxHeight*numChars*1' bytes, but '2' bytes may be written: Lines: 479, 480, 481, 482, 484, 486, 487, 488, 493, 494, 496, 509, 510, 512, 514, 515, 521, 523, 532, 534, 535, 536, 538, 539, 540, 541, 543, 544, 546, 548, 549, 550, 551, 557, 546, 560, 544, 546, 548

ScummRP

src\ScummRp\block.hpp(105) : warning C26439: This kind of function may not throw. Declare it 'noexcept'. (f.6).
src\ScummRp\file.cpp(728) : warning C6001: using uninitialized memory 'buffer'.: Lines: 716, 718, 719, 723, 728

src\ScummRp\block.cpp(379) : warning C6001: using uninitialized memory 'subblock'.: Lines: 368, 370, 373, 379
src\ScummRp\block.cpp(871) : warning C6001: using uninitialized memory 'subblock'.: Lines: 845, 846, 847, 849, 850, 854, 855, 858, 861, 871
src\ScummRp\block.cpp(969) : warning C6001: using uninitialized memory 'subblock'.: Lines: 943, 944, 945, 947, 948, 952, 953, 956, 959, 969
src\ScummRp\block.cpp(1755) : warning C6001: using uninitialized memory 'subblock'.: Lines: 1629, 1630, 1631, 1632, 1633, 1635, 1636, 1641, 1660, 1661, 1755
@dwatteau dwatteau changed the title [Build warning] Various warnings from MSVC analysis tool [Build warning] Various warnings from analysis tools Nov 25, 2021
@dwatteau
Copy link
Owner Author

dwatteau commented Nov 25, 2021

Some clang-tidy warnings from enableClangTidyCodeAnalysis in Visual Studio.

src\ScummTr\script.hpp:71:49: warning: 1 uninitialized field at the end of the constructor call [clang-analyzer-optin.cplusplus.UninitializedObject]
             
   JumpRef(int32 o, int32 t) : offset(o), target(t) { }
                                                              ^
src\ScummTr\script.hpp:69:8: note: uninitialized field 'this->valid'
                bool valid;
                     ^
src\ScummTr\script.cpp:434:2: note: Control jumps to 'case 115:'  at line 566
        switch (opcode)
        ^
src\ScummTr\script.cpp:567:3: note: Calling 'Script::_eatJump'
                _eatJump();
                ^
src\ScummTr\script.cpp:386:6: note: Assuming field '_log' is true
        if (_log)
            ^
src\ScummTr\script.cpp:386:2: note: Taking true branch
        if (_log)
        ^
src\ScummTr\script.cpp:387:19: note: Calling constructor for 'JumpRef'
                _jump.push_back(JumpRef(offset, val + offset + sizeof(int16)));
                                ^
src\ScummTr\script.hpp:71:49: note: 1 uninitialized field at the end of the constructor call
                JumpRef(int32 o, int32 t) : offset(o), target(t) { }

bool valid in JumpRef is actually completely unused. To be removed (EDIT: done).


src\common\toolbox.cpp:54:2: warning: Function 'vsnprintf' is called with an uninitialized va_list argument [clang-analyzer-valist.Uninitialized]
        vsnprintf(errorMessage[currentStr], MAX_MSG_SIZE, format, va);
        ^
src\common\toolbox.cpp:54:2: note: Function 'vsnprintf' is called with an uninitialized va_list argument

appears to be a false positive / clang-tidy bug. (EDIT: let's just ignore it)


src\common\file.cpp:819:90: warning: format specifies type 'unsigned int' but the argument has type 'std::streamoff' (aka 'long long') [clang-diagnostic-format]
                throw File::UnexpectedEOF(xsprintf("Unexpected EOF in: %s <0x%X, 0x%X>", _file->_path, _offset, _size));
                                                                             ~~                        ^
                                                                             %llX
src\common\file.cpp:819:99: warning: format specifies type 'unsigned int' but the argument has type 'std::streamsize' (aka 'long long') [clang-diagnostic-format]
                throw File::UnexpectedEOF(xsprintf("Unexpected EOF in: %s <0x%X, 0x%X>", _file->_path, _offset, _size));
                                                                                   ~~                           ^
                                                                                   %llX
src\ScummTr\script.cpp:300:79: warning: format specifies type 'unsigned int' but the argument has type 'long long' [clang-diagnostic-format]
                throw Script::ParseError(xsprintf("Unexpected end of script at 0x%X in %s", _file->fullOffset() + _file->tellg(std::ios::beg), _file->name().c_str()));
                                                                                 ~~         ^
                                                                                 %llX
src\ScummTr\script.cpp:304:72: warning: format specifies type 'unsigned int' but the argument has type 'long long' [clang-diagnostic-format]
                throw Script::ParseError(xsprintf("Script error at 0x%X in %s (%s)", _file->fullOffset() + _file->tellg(std::ios::beg), _file->name().c_str(), e.what()));
                                                                     ~~              ^
                                                                     %llX
src\ScummTr\script.cpp:373:73: warning: format specifies type 'unsigned int' but the argument has type 'std::streamoff' (aka 'long long') [clang-diagnostic-format]
                        throw Script::ParseError(xsprintf("Arg list too long at 0x%X in %s", _file->fullOffset(), _file->name().c_str()));
                                                                                  ~~         ^
                                                                                  %llX

legitimate, but probably non-critical since we only deal with small files.

@dwatteau dwatteau self-assigned this Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant