Bitcoin Core Fuzz Coverage Report

Coverage Report

Created: 2026-03-24 13:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/bitcoin/src/noui.cpp
Line
Count
Source
1
// Copyright (c) 2010 Satoshi Nakamoto
2
// Copyright (c) 2009-present The Bitcoin Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#include <noui.h>
7
8
#include <logging.h>
9
#include <node/interface_ui.h>
10
#include <util/translation.h>
11
12
#include <string>
13
14
#include <boost/signals2/connection.hpp>
15
#include <boost/signals2/signal.hpp>
16
17
/** Store connections so we can disconnect them when suppressing output */
18
boost::signals2::connection noui_ThreadSafeMessageBoxConn;
19
boost::signals2::connection noui_ThreadSafeQuestionConn;
20
boost::signals2::connection noui_InitMessageConn;
21
22
bool noui_ThreadSafeMessageBox(const bilingual_str& message, unsigned int style)
23
0
{
24
0
    bool fSecure = style & CClientUIInterface::SECURE;
25
0
    style &= ~CClientUIInterface::SECURE;
26
27
0
    std::string strCaption;
28
0
    switch (style) {
29
0
    case CClientUIInterface::MSG_ERROR:
30
0
        strCaption = "Error: ";
31
0
        if (!fSecure) LogError("%s\n", message.original);
Line
Count
Source
97
0
#define LogError(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, /*should_ratelimit=*/true, __VA_ARGS__)
Line
Count
Source
89
0
#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
32
0
        break;
33
0
    case CClientUIInterface::MSG_WARNING:
34
0
        strCaption = "Warning: ";
35
0
        if (!fSecure) LogWarning("%s\n", message.original);
Line
Count
Source
96
0
#define LogWarning(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Warning, /*should_ratelimit=*/true, __VA_ARGS__)
Line
Count
Source
89
0
#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
36
0
        break;
37
0
    case CClientUIInterface::MSG_INFORMATION:
38
0
        strCaption = "Information: ";
39
0
        if (!fSecure) LogInfo("%s\n", message.original);
Line
Count
Source
95
0
#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__)
Line
Count
Source
89
0
#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
40
0
        break;
41
0
    default:
42
0
        if (!fSecure) LogInfo("%s%s\n", strCaption, message.original);
Line
Count
Source
95
0
#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__)
Line
Count
Source
89
0
#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
43
0
    }
44
45
0
    tfm::format(std::cerr, "%s%s\n", strCaption, message.original);
46
0
    return false;
47
0
}
48
49
bool noui_ThreadSafeQuestion(const bilingual_str& /* ignored interactive message */, const std::string& message, unsigned int style)
50
0
{
51
0
    return noui_ThreadSafeMessageBox(Untranslated(message), style);
52
0
}
53
54
void noui_InitMessage(const std::string& message)
55
0
{
56
0
    LogInfo("init message: %s", message);
Line
Count
Source
95
0
#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__)
Line
Count
Source
89
0
#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
57
0
}
58
59
void noui_connect()
60
0
{
61
0
    noui_ThreadSafeMessageBoxConn = uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
62
0
    noui_ThreadSafeQuestionConn = uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
63
0
    noui_InitMessageConn = uiInterface.InitMessage_connect(noui_InitMessage);
64
0
}
65
66
bool noui_ThreadSafeMessageBoxRedirect(const bilingual_str& message, unsigned int style)
67
0
{
68
0
    LogInfo("%s", message.original);
Line
Count
Source
95
0
#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__)
Line
Count
Source
89
0
#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
69
0
    return false;
70
0
}
71
72
bool noui_ThreadSafeQuestionRedirect(const bilingual_str& /* ignored interactive message */, const std::string& message, unsigned int style)
73
0
{
74
0
    LogInfo("%s", message);
Line
Count
Source
95
0
#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__)
Line
Count
Source
89
0
#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
75
0
    return false;
76
0
}
77
78
void noui_InitMessageRedirect(const std::string& message)
79
0
{
80
0
    LogInfo("init message: %s", message);
Line
Count
Source
95
0
#define LogInfo(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__)
Line
Count
Source
89
0
#define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
81
0
}
82
83
void noui_test_redirect()
84
0
{
85
0
    noui_ThreadSafeMessageBoxConn.disconnect();
86
0
    noui_ThreadSafeQuestionConn.disconnect();
87
0
    noui_InitMessageConn.disconnect();
88
0
    noui_ThreadSafeMessageBoxConn = uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBoxRedirect);
89
0
    noui_ThreadSafeQuestionConn = uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestionRedirect);
90
0
    noui_InitMessageConn = uiInterface.InitMessage_connect(noui_InitMessageRedirect);
91
0
}
92
93
void noui_reconnect()
94
0
{
95
0
    noui_ThreadSafeMessageBoxConn.disconnect();
96
0
    noui_ThreadSafeQuestionConn.disconnect();
97
0
    noui_InitMessageConn.disconnect();
98
0
    noui_connect();
99
0
}