#6559 Regression/ false positive: Return value of allocation function OpenFile is not stored. Add required definitions to windows.cfg, include afx_msg. Add test file test/cfg/windows.cpp to check windows configuration. Fix for gnu.cfg. FileLister now features a non-recursive mode.

This commit is contained in:
Alexander Mai 2015-03-05 06:48:44 +01:00
parent 6646a896f9
commit b5f0eec44a
5 changed files with 49 additions and 8 deletions

View File

@ -126,7 +126,7 @@
<arg nr="6"/>
</function>
<!-- int fcvt_r (double value, int ndigit, int *decpt, int *neg, char *buf, size_t len); -->
<function name="ecvt_r">
<function name="fcvt_r">
<noreturn>false</noreturn>
<arg nr="1">
<not-uninit/>

View File

@ -1444,9 +1444,27 @@
<not-null/>
</arg>
</function>
<function name="CloseHandle">
<noreturn>false</noreturn>
<arg nr="1">
<not-uninit/>
</arg>
</function>
<function name="OpenFile">
<noreturn>false</noreturn>
<arg nr="1">
<not-uninit/>
<not-null/>
</arg>
<arg nr="2"/>
<arg nr="3">
<not-uninit/>
</arg>
</function>
<podtype name="LARGE_INTEGER" sign="s" size="8"/>
<podtype name="POINTER_SIGNED" sign="s"/>
<podtype name="POINTER_UNSIGNED" sign="u"/>
<podtype name="ULARGE_INTEGER" sign="u" size="8"/>
<define name="INVALID_HANDLE_VALUE" value="0"/>
<define name="afx_msg" value=""/>
</def>

View File

@ -17,6 +17,10 @@ ${CPPCHECK} --check-library --library=posix --enable=information --enable=style
gcc -fsyntax-only -D_GNU_SOURCE ${DIR}gnu.c
${CPPCHECK} --check-library --library=gnu --enable=information --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr ${DIR}gnu.c
# windows.cpp
#g++ -fsyntax-only ${DIR}windows.cpp
${CPPCHECK} --check-library --library=windows --enable=information --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr ${DIR}windows.cpp
# std.c
gcc -fsyntax-only ${DIR}std.c
${CPPCHECK} --check-library --enable=information --error-exitcode=1 --enable=style --suppress=missingIncludeSystem --inline-suppr ${DIR}std.c

18
test/cfg/windows.cpp Normal file
View File

@ -0,0 +1,18 @@
// Test library configuration for windows.cfg
//
// Usage:
// $ cppcheck --check-library --library=windows --enable=information --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/windows.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
class CSharedFilesCtrl {
void OpenFile(const CShareableFile* file);
afx_msg void OnNmDblClk(NMHDR *pNMHDR, LRESULT *pResult);
};
void CSharedFilesCtrl::OnNmDblClk(NMHDR* /*pNMHDR*/, LRESULT* pResult) {
if (file)
OpenFile(file);
}

View File

@ -87,10 +87,11 @@ static void compilefiles(std::ostream &fout, const std::vector<std::string> &fil
}
}
static void getCppFiles(std::vector<std::string> &files, const std::string &path)
static void getCppFiles(std::vector<std::string> &files, const std::string &path, bool recursive)
{
std::map<std::string,size_t> filemap;
FileLister::recursiveAddFiles(filemap, path);
const std::set<std::string> extra;
FileLister::addFiles(filemap, path, extra, recursive);
// add *.cpp files to the "files" vector..
for (std::map<std::string,size_t>::const_iterator it = filemap.begin(); it != filemap.end(); ++it) {
@ -153,16 +154,16 @@ int main(int argc, char **argv)
// Get files..
std::vector<std::string> libfiles;
getCppFiles(libfiles, "lib/");
getCppFiles(libfiles, "lib/", false);
std::vector<std::string> clifiles;
getCppFiles(clifiles, "cli/");
getCppFiles(clifiles, "cli/", false);
std::vector<std::string> testfiles;
getCppFiles(testfiles, "test/");
getCppFiles(testfiles, "test/", false);
std::vector<std::string> toolsfiles;
getCppFiles(toolsfiles, "tools/");
getCppFiles(toolsfiles, "tools/", false);
if (libfiles.empty() && clifiles.empty() && testfiles.empty()) {
std::cerr << "No files found. Are you in the correct directory?" << std::endl;
@ -170,7 +171,7 @@ int main(int argc, char **argv)
}
std::vector<std::string> externalfiles;
getCppFiles(externalfiles, "externals/");
getCppFiles(externalfiles, "externals/", true);
// QMAKE - lib/lib.pri