Skip to content

Commit 6f47210

Browse files
committed
Resolve coverity defects concerning potential dead code and uncaught exceptions
1 parent 0586189 commit 6f47210

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

tinyformat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ inline void formatValue(std::ostream& out, const char* /*fmtBegin*/,
318318
// void* respectively and format that instead of the value itself. For the
319319
// %p conversion it's important to avoid dereferencing the pointer, which
320320
// could otherwise lead to a crash when printing a dangling (const char*).
321-
bool canConvertToChar = detail::is_convertible<T,char>::value;
322-
bool canConvertToVoidPtr = detail::is_convertible<T, const void*>::value;
321+
const bool canConvertToChar = detail::is_convertible<T,char>::value;
322+
const bool canConvertToVoidPtr = detail::is_convertible<T, const void*>::value;
323323
if(canConvertToChar && *(fmtEnd-1) == 'c')
324324
detail::formatValueAsType<T, char>::invoke(out, value);
325325
else if(canConvertToVoidPtr && *(fmtEnd-1) == 'p')

tinyformat_test.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,13 @@ int unitTests()
266266

267267
int main()
268268
{
269-
return unitTests();
269+
try
270+
{
271+
return unitTests();
272+
}
273+
catch (std::runtime_error & e)
274+
{
275+
std::cout << "Failure due to uncaught exception: " << e.what() << std::endl;
276+
return EXIT_FAILURE;
277+
}
270278
}

0 commit comments

Comments
 (0)