Skip to content

Commit b82c55a

Browse files
Add attribute [[noreturn]] (C++11) to functions that will not return
Rationale: * Reduce the number of false positives from static analyzers * Potentially enable additional compiler optimizations
1 parent 5cfdda2 commit b82c55a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/random.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
#include <openssl/err.h>
4040
#include <openssl/rand.h>
4141

42-
static void RandFailure()
42+
[[noreturn]] static void RandFailure()
4343
{
4444
LogPrintf("Failed to read randomness, aborting\n");
45-
abort();
45+
std::abort();
4646
}
4747

4848
static inline int64_t GetPerformanceCounter()

src/test/test_bitcoin_main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
std::unique_ptr<CConnman> g_connman;
1212

13-
void Shutdown(void* parg)
13+
[[noreturn]] void Shutdown(void* parg)
1414
{
15-
exit(EXIT_SUCCESS);
15+
std::exit(EXIT_SUCCESS);
1616
}
1717

18-
void StartShutdown()
18+
[[noreturn]] void StartShutdown()
1919
{
20-
exit(EXIT_SUCCESS);
20+
std::exit(EXIT_SUCCESS);
2121
}
2222

2323
bool ShutdownRequested()

0 commit comments

Comments
 (0)