Skip to content

Commit ee17695

Browse files
committed
Suppress false positives from coverity
1 parent c9de4ee commit ee17695

17 files changed

+25
-36
lines changed

src/cstdio.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace nowide {
4343
{
4444
const wstackstring wname(file_name);
4545
const wshort_stackstring wmode(mode);
46-
return _wfreopen(wname.get(), wmode.get(), stream);
46+
return _wfreopen(wname.get(), wmode.get(), stream); // coverity[var_deref_model]
4747
}
4848
///
4949
/// \brief Same as fopen but file_name and mode are UTF-8 strings
@@ -52,7 +52,7 @@ namespace nowide {
5252
{
5353
const wstackstring wname(file_name);
5454
const wshort_stackstring wmode(mode);
55-
return detail::wfopen(wname.get(), wmode.get());
55+
return detail::wfopen(wname.get(), wmode.get()); // coverity[var_deref_model]
5656
}
5757
///
5858
/// \brief Same as rename but old_name and new_name are UTF-8 strings

test/test.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ int main(int argc, char** argv, char** env)
111111
{
112112
try
113113
{
114+
#ifdef _MSC_VER
115+
std::cout << "MSVC version " << _MSC_VER << std::endl;
116+
#endif
114117
test_main(argc, argv, env);
115118
} catch(const std::exception& e)
116119
{
117120
std::cerr << "Failed " << e.what() << std::endl;
118-
#ifdef _MSC_VER
119-
std::cerr << "MSVC version " << _MSC_VER << std::endl;
120-
#endif
121121
return 1;
122122
}
123123
return 0;

test/test_codecvt.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,7 @@ void test_codecvt_subst()
412412
run_all(codecvt_to_wide, codecvt_to_narrow);
413413
}
414414

415-
// coverity [root_function]
416-
void test_main(int, char**, char**)
415+
void test_main(int, char**, char**) // coverity [root_function]
417416
{
418417
test_codecvt_basic();
419418
test_codecvt_unshift();

test/test_convert.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ std::string narrow_string_view(const std::wstring& s)
127127
}
128128
#endif
129129

130-
// coverity [root_function]
131-
void test_main(int, char**, char**)
130+
void test_main(int, char**, char**) // coverity [root_function]
132131
{
133132
std::string hello = "\xd7\xa9\xd7\x9c\xd7\x95\xd7\x9d";
134133
std::wstring whello = L"\u05e9\u05dc\u05d5\u05dd";

test/test_env.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
#include <windows.h>
1515
#endif
1616

17-
// coverity [root_function]
18-
void test_main(int, char**, char**)
17+
void test_main(int, char**, char**) // coverity [root_function]
1918
{
2019
std::string example = "\xd7\xa9-\xd0\xbc-\xce\xbd";
2120
std::string envVar = "BOOST_TEST2=" + example + "x";

test/test_filebuf.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,13 @@ void test_64_bit_seek(const std::string& filepath)
138138
#pragma warning(disable : 4127)
139139
#endif
140140
// if we can't use 64 bit offsets through the API, don't test anything
141+
// LCOV_EXCL_START
141142
// coverity[result_independent_of_operands]
142143
if(offset == nw::filebuf::off_type(0))
143-
return; // LCOV_EXCL_LINE coverity[dead_error_line]
144+
{
145+
return; // coverity[dead_error_line]
146+
}
147+
// LCOV_EXCL_STOP
144148
#ifdef BOOST_MSVC
145149
#pragma warning(pop)
146150
#endif
@@ -298,8 +302,7 @@ void test_swap(const std::string& filepath)
298302
}
299303
}
300304

301-
// coverity [root_function]
302-
void test_main(int, char** argv, char**)
305+
void test_main(int, char** argv, char**) // coverity [root_function]
303306
{
304307
const std::string exampleFilename = std::string(argv[0]) + "-\xd7\xa9-\xd0\xbc-\xce\xbd.txt";
305308

test/test_fs.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
#endif
2222
#include <boost/filesystem/operations.hpp>
2323

24-
// coverity [root_function]
25-
void test_main(int, char** argv, char**)
24+
void test_main(int, char** argv, char**) // coverity [root_function]
2625
{
2726
boost::nowide::nowide_filesystem();
2827
const std::string prefix = argv[0];

test/test_fstream.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,7 @@ void test_flush(const std::string& filepath)
533533
TEST(!fo.seekg(0)); // Does not work on closed stream
534534
}
535535

536-
// coverity [root_function]
537-
void test_main(int, char** argv, char**)
536+
void test_main(int, char** argv, char**) // coverity [root_function]
538537
{
539538
const std::string exampleFilename = std::string(argv[0]) + "-\xd7\xa9-\xd0\xbc-\xce\xbd.txt";
540539

test/test_fstream_special.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ void testPutback(const char* filename)
257257
}
258258
}
259259

260-
// coverity [root_function]
261-
void test_main(int, char** argv, char**)
260+
void test_main(int, char** argv, char**) // coverity [root_function]
262261
{
263262
const std::string exampleFilename = std::string(argv[0]) + "-\xd7\xa9-\xd0\xbc-\xce\xbd.txt";
264263
const std::string exampleFilename2 = std::string(argv[0]) + "-\xd7\xa9-\xd0\xbc-\xce\xbd 2.txt";

test/test_ifstream.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ void test_move_and_swap(const std::string& filename)
199199
}
200200
}
201201

202-
// coverity [root_function]
203-
void test_main(int, char** argv, char**)
202+
void test_main(int, char** argv, char**) // coverity [root_function]
204203
{
205204
const std::string exampleFilename = std::string(argv[0]) + "-\xd7\xa9-\xd0\xbc-\xce\xbd.txt";
206205

0 commit comments

Comments
 (0)