Skip to content

Commit

Permalink
Updated rapidjson
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Dec 2, 2024
1 parent 94da2e8 commit cf325e0
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 12 deletions.
12 changes: 11 additions & 1 deletion cppcheck/run.cmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
@echo off
"..\cppcheck-main\bin\cppcheck.exe" ../src/*.cpp -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN -D_WIN32=1 -D_WIN64=1 -DWIN32=1 -D_WINDOWS=1 -DNDEBUG=1 -DWITH_GRPC=1 -DPROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII=0 -DWITH_RANDOMX=1 -DWITH_UPNP=1 -DCURL_STATICLIB=1 -DWIN32_LEAN_AND_MEAN=1 -D_WIN32_WINNT=0x0600 -D_DISABLE_VECTOR_ANNOTATION=1 -D_DISABLE_STRING_ANNOTATION=1 -DZMQ_STATIC=1 -DHAVE_BITSCANREVERSE64=1 -DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag -DMINIUPNP_STATICLIB=1 -DCARES_STATICLIB=1 -DCMAKE_INTDIR="Release" -D__SSE2__=1 -D_MSC_VER=1929 -D__COVERITY__ --platform=win64 --std=c++17 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --includes-file=includes.txt --suppressions-list=suppressions.txt --output-file=errors_full.txt --max-ctu-depth=3 --check-level=exhaustive --checkers-report=checkers_report.txt
"..\cppcheck-main\bin\cppcheck.exe" ../src/*.cpp -D__cppcheck__ -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN -D_WIN32=1 -D_WIN64=1 -DWIN32=1 -D_WINDOWS=1 -DNDEBUG=1 -DWITH_GRPC=1 -DPROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII=0 -DWITH_RANDOMX=1 -DWITH_UPNP=1 -DCURL_STATICLIB=1 -DWIN32_LEAN_AND_MEAN=1 -D_WIN32_WINNT=0x0600 -D_DISABLE_VECTOR_ANNOTATION=1 -D_DISABLE_STRING_ANNOTATION=1 -DZMQ_STATIC=1 -DHAVE_BITSCANREVERSE64=1 -DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag -DMINIUPNP_STATICLIB=1 -DCARES_STATICLIB=1 -DCMAKE_INTDIR="Release" -D__SSE2__=1 -D_MSC_VER=1929 -D__COVERITY__ --platform=win64 --std=c++17 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --includes-file=includes.txt --suppressions-list=suppressions.txt --output-file=errors_full.txt --max-ctu-depth=3 --check-level=exhaustive --checkers-report=checkers_report.txt

findstr /V /C:"external\src" errors_full.txt > errors_filtered0.txt
findstr /V /C:":checkersReport" errors_filtered0.txt > errors_filtered.txt

findstr /C:"There were critical errors" checkers_report.txt > checkers_report_filtered.txt

for /f %%i in ("errors_filtered.txt") do set size=%%~zi
if %size% gtr 0 (
type errors_filtered.txt
exit 1
)

for /f %%i in ("checkers_report_filtered.txt") do set size2=%%~zi
if %size2% gtr 0 (
type checkers_report_filtered.txt
exit 1
)
9 changes: 9 additions & 0 deletions cppcheck/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/bin/bash
../cppcheck-main/cppcheck --project=../build/compile_commands.json -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN -DRAPIDJSON_64BIT=1 -D__SSE2__=1 -D__BYTE_ORDER__=1 -D__ORDER_LITTLE_ENDIAN__=1 -D__linux__=1 -D__x86_64 -D_M_AMD64 -D_M_X64 --platform=unix64 --std=c++17 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --suppressions-list=suppressions.txt --output-file=errors_full.txt --max-ctu-depth=3 --check-level=exhaustive --checkers-report=checkers_report.txt

grep -v 'external' errors_full.txt > errors_filtered0.txt
grep -v ':checkersReport' errors_filtered0.txt > errors_filtered.txt

grep 'There were critical errors' checkers_report.txt > checkers_report_filtered.txt

if [ -s errors_filtered.txt ]; then
cat errors_filtered.txt
exit 1
fi

if [ -s checkers_report_filtered.txt ]; then
cat checkers_report_filtered.txt
exit 1
fi
2 changes: 1 addition & 1 deletion src/merge_mining_client_json_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "params.h"
#include "json_rpc_request.h"
#include "json_parsers.h"
#include <rapidjson/document.h>
#include "rapidjson_wrapper.h"

LOG_CATEGORY(MergeMiningClientJSON_RPC)

Expand Down
2 changes: 1 addition & 1 deletion src/p2p_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "block_template.h"
#include "p2pool_api.h"
#include "stratum_server.h"
#include <rapidjson/document.h>
#include "rapidjson_wrapper.h"
#include <fstream>
#include <numeric>

Expand Down
2 changes: 1 addition & 1 deletion src/p2pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "zmq_reader.h"
#include "mempool.h"
#include "json_rpc_request.h"
#include "rapidjson/document.h"
#include "rapidjson_wrapper.h"
#include "json_parsers.h"
#include "pow_hash.h"
#include "block_template.h"
Expand Down
2 changes: 1 addition & 1 deletion src/pow_hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#endif
#include "json_rpc_request.h"
#include "json_parsers.h"
#include <rapidjson/document.h>
#include "rapidjson_wrapper.h"
#include <thread>

LOG_CATEGORY(RandomX_Hasher)
Expand Down
5 changes: 5 additions & 0 deletions src/rapidjson_wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#if defined(_MSC_VER) && defined(__cppcheck__)
// cppcheck chokes on rapidjson headers in Windows
#else
#include <rapidjson/document.h>
#endif
4 changes: 4 additions & 0 deletions src/side_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@
#include "json_parsers.h"
#include "crypto.h"
#include "hardforks/hardforks.h"

#if !defined(_MSC_VER) || !defined(__cppcheck__)
#include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h>
#endif

#include <fstream>
#include <iterator>
#include <numeric>
Expand Down
8 changes: 6 additions & 2 deletions src/stratum_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "p2pool_api.h"
#include "p2p_server.h"

#include "rapidjson_wrapper.h"

LOG_CATEGORY(StratumServer)

static constexpr int DEFAULT_BACKLOG = 128;
Expand Down Expand Up @@ -1311,7 +1313,8 @@ bool StratumServer::StratumClient::process_request(char* data, uint32_t size)
return false;
}

bool StratumServer::StratumClient::process_login(rapidjson::Document& doc, uint32_t id)
template<typename T>
bool StratumServer::StratumClient::process_login(T& doc, uint32_t id)
{
const auto params_it = doc.FindMember("params");
if (params_it == doc.MemberEnd()) {
Expand Down Expand Up @@ -1340,7 +1343,8 @@ bool StratumServer::StratumClient::process_login(rapidjson::Document& doc, uint3
return static_cast<StratumServer*>(m_owner)->on_login(this, id, login.GetString());
}

bool StratumServer::StratumClient::process_submit(rapidjson::Document& doc, uint32_t id)
template<typename T>
bool StratumServer::StratumClient::process_submit(T& doc, uint32_t id)
{
const auto params_it = doc.FindMember("params");
if (params_it == doc.MemberEnd()) {
Expand Down
5 changes: 2 additions & 3 deletions src/stratum_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#pragma once

#include "tcp_server.h"
#include <rapidjson/document.h>

namespace p2pool {

Expand Down Expand Up @@ -50,8 +49,8 @@ class StratumServer : public TCPServer
[[nodiscard]] bool on_read(const char* data, uint32_t size) override;

[[nodiscard]] bool process_request(char* data, uint32_t size);
[[nodiscard]] bool process_login(rapidjson::Document& doc, uint32_t id);
[[nodiscard]] bool process_submit(rapidjson::Document& doc, uint32_t id);
template<typename T> [[nodiscard]] bool process_login(T& doc, uint32_t id);
template<typename T> [[nodiscard]] bool process_submit(T& doc, uint32_t id);

bool send_http_response(bool send_content);

Expand Down
2 changes: 1 addition & 1 deletion src/zmq_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "common.h"
#include "zmq_reader.h"
#include "json_parsers.h"
#include <rapidjson/document.h>
#include "rapidjson_wrapper.h"

LOG_CATEGORY(ZMQReader)

Expand Down

0 comments on commit cf325e0

Please sign in to comment.