From 6a3520164a30900857b3e3015c3225baa9fa19ac Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Tue, 10 May 2022 09:50:02 +0200 Subject: [PATCH] std.cfg: Improved configuration of std::ifstream::open() and std::ios_base::open(). --- cfg/std.cfg | 8 ++++++-- test/cfg/std.cpp | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index 44ca631d8..07924867f 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -7182,7 +7182,9 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init false - + + + @@ -7193,7 +7195,9 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init false - + + + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index a73e98358..5f6a54b17 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -33,6 +33,29 @@ #include #include +void nullPointer_std_ifstream_open(std::fstream &fs, const std::string &strFileName, const char* filename, std::ios_base::openmode mode) +{ + // cppcheck-suppress nullPointer + fs.open(nullptr, mode); + fs.open(filename, mode); + fs.open(strFileName, mode); + // cppcheck-suppress nullPointer + fs.open(nullptr); + fs.open(filename); + fs.open(strFileName); +} + +void nullPointer_std_ifstream_open(std::ifstream &is, const std::string &strFileName, const char* filename, std::ios_base::openmode mode) +{ + // cppcheck-suppress nullPointer + is.open(nullptr, mode); + is.open(filename, mode); + is.open(strFileName, mode); + // cppcheck-suppress nullPointer + is.open(nullptr); + is.open(filename); + is.open(strFileName); +} void bufferAccessOutOfBounds_std_fstream_write(std::fstream &fs, const char* s, std::streamsize n) {