Skip to content

Commit

Permalink
Merge pull request bitcoin#3262 from PastaPastaPasta/backports-0.16-p…
Browse files Browse the repository at this point in the history
…r1-almost-trivial

Backports 0.16 pr1-2: almost trivial
  • Loading branch information
UdjinM6 committed Jan 3, 2020
2 parents ca63ad3 + 9044d53 commit 1da2ac5
Show file tree
Hide file tree
Showing 87 changed files with 237 additions and 558 deletions.
3 changes: 2 additions & 1 deletion contrib/devtools/check-doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from subprocess import check_output
import re
import sys

FOLDER_GREP = 'src'
FOLDER_TEST = 'src/test/'
Expand Down Expand Up @@ -39,7 +40,7 @@ def main():
print("Args unknown : {}".format(len(args_unknown)))
print(args_unknown)

exit(len(args_need_doc))
sys.exit(len(args_need_doc))

if __name__ == "__main__":
main()
41 changes: 21 additions & 20 deletions contrib/devtools/github-merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import argparse
import hashlib
import subprocess
import sys
import json,codecs
try:
from urllib.request import Request,urlopen
Expand Down Expand Up @@ -158,11 +159,11 @@ def main():
if repo is None:
print("ERROR: No repository configured. Use this command to set:", file=stderr)
print("git config githubmerge.repository <owner>/<repo>", file=stderr)
exit(1)
sys.exit(1)
if signingkey is None:
print("ERROR: No GPG signing key set. Set one using:",file=stderr)
print("git config --global user.signingkey <key>",file=stderr)
exit(1)
sys.exit(1)

host_repo = host+":"+repo # shortcut for push/pull target

Expand All @@ -173,7 +174,7 @@ def main():
# Receive pull information from github
info = retrieve_pr_info(repo,pull)
if info is None:
exit(1)
sys.exit(1)
title = info['title'].strip()
body = info['body'].strip()
# precedence order for destination branch argument:
Expand All @@ -194,27 +195,27 @@ def main():
subprocess.check_call([GIT,'checkout','-q',branch])
except subprocess.CalledProcessError as e:
print("ERROR: Cannot check out branch %s." % (branch), file=stderr)
exit(3)
sys.exit(3)
try:
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/pull/'+pull+'/*:refs/heads/pull/'+pull+'/*'])
except subprocess.CalledProcessError as e:
print("ERROR: Cannot find pull request #%s on %s." % (pull,host_repo), file=stderr)
exit(3)
sys.exit(3)
try:
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+head_branch], stdout=devnull, stderr=stdout)
except subprocess.CalledProcessError as e:
print("ERROR: Cannot find head of pull request #%s on %s." % (pull,host_repo), file=stderr)
exit(3)
sys.exit(3)
try:
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+merge_branch], stdout=devnull, stderr=stdout)
except subprocess.CalledProcessError as e:
print("ERROR: Cannot find merge of pull request #%s on %s." % (pull,host_repo), file=stderr)
exit(3)
sys.exit(3)
try:
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/heads/'+branch+':refs/heads/'+base_branch])
except subprocess.CalledProcessError as e:
print("ERROR: Cannot find branch %s on %s." % (branch,host_repo), file=stderr)
exit(3)
sys.exit(3)
subprocess.check_call([GIT,'checkout','-q',base_branch])
subprocess.call([GIT,'branch','-q','-D',local_merge_branch], stderr=devnull)
subprocess.check_call([GIT,'checkout','-q','-b',local_merge_branch])
Expand All @@ -236,30 +237,30 @@ def main():
except subprocess.CalledProcessError as e:
print("ERROR: Cannot be merged cleanly.",file=stderr)
subprocess.check_call([GIT,'merge','--abort'])
exit(4)
sys.exit(4)
logmsg = subprocess.check_output([GIT,'log','--pretty=format:%s','-n','1']).decode('utf-8')
if logmsg.rstrip() != firstline.rstrip():
print("ERROR: Creating merge failed (already merged?).",file=stderr)
exit(4)
sys.exit(4)

symlink_files = get_symlink_files()
for f in symlink_files:
print("ERROR: File %s was a symlink" % f)
if len(symlink_files) > 0:
exit(4)
sys.exit(4)

# Put tree SHA512 into the message
try:
first_sha512 = tree_sha512sum()
message += '\n\nTree-SHA512: ' + first_sha512
except subprocess.CalledProcessError as e:
printf("ERROR: Unable to compute tree hash")
exit(4)
print("ERROR: Unable to compute tree hash")
sys.exit(4)
try:
subprocess.check_call([GIT,'commit','--amend','-m',message.encode('utf-8')])
except subprocess.CalledProcessError as e:
printf("ERROR: Cannot update message.",file=stderr)
exit(4)
print("ERROR: Cannot update message.", file=stderr)
sys.exit(4)

print_merge_details(pull, title, branch, base_branch, head_branch)
print()
Expand All @@ -268,7 +269,7 @@ def main():
if testcmd:
if subprocess.call(testcmd,shell=True):
print("ERROR: Running %s failed." % testcmd,file=stderr)
exit(5)
sys.exit(5)

# Show the created merge.
diff = subprocess.check_output([GIT,'diff',merge_branch+'..'+local_merge_branch])
Expand All @@ -279,7 +280,7 @@ def main():
if reply.lower() == 'ignore':
print("Difference with github ignored.",file=stderr)
else:
exit(6)
sys.exit(6)
else:
# Verify the result manually.
print("Dropping you on a shell so you can try building/testing the merged source.",file=stderr)
Expand All @@ -292,7 +293,7 @@ def main():
second_sha512 = tree_sha512sum()
if first_sha512 != second_sha512:
print("ERROR: Tree hash changed unexpectedly",file=stderr)
exit(8)
sys.exit(8)

# Sign the merge commit.
print_merge_details(pull, title, branch, base_branch, head_branch)
Expand All @@ -306,7 +307,7 @@ def main():
print("Error while signing, asking again.",file=stderr)
elif reply == 'x':
print("Not signing off on merge, exiting.",file=stderr)
exit(1)
sys.exit(1)

# Put the result in branch.
subprocess.check_call([GIT,'checkout','-q',branch])
Expand All @@ -326,7 +327,7 @@ def main():
subprocess.check_call([GIT,'push',host_repo,'refs/heads/'+branch])
break
elif reply == 'x':
exit(1)
sys.exit(1)

if __name__ == '__main__':
main()
Expand Down
2 changes: 1 addition & 1 deletion contrib/devtools/security-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,5 @@ def identify_executable(executable):
except IOError:
print('%s: cannot open' % filename)
retval = 1
exit(retval)
sys.exit(retval)

2 changes: 1 addition & 1 deletion contrib/devtools/symbol-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ def read_libraries(filename):
print('%s: NEEDED library %s is not allowed' % (filename, library_name))
retval = 1

exit(retval)
sys.exit(retval)


4 changes: 2 additions & 2 deletions contrib/devtools/update-translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def check_at_repository_root():
if not os.path.exists('.git'):
print('No .git directory found')
print('Execute this script at the root of the repository', file=sys.stderr)
exit(1)
sys.exit(1)

def fetch_all_translations():
if subprocess.call([TX, 'pull', '-f', '-a']):
print('Error while fetching translations', file=sys.stderr)
exit(1)
sys.exit(1)

def find_format_specifiers(s):
'''Find all format specifiers in a string.'''
Expand Down
4 changes: 2 additions & 2 deletions contrib/linearize/linearize-hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_block_hashes(settings, max_blocks_per_call=10000):
for x,resp_obj in enumerate(reply):
if rpc.response_is_error(resp_obj):
print('JSON-RPC: error at height', height+x, ': ', resp_obj['error'], file=sys.stderr)
exit(1)
sys.exit(1)
assert(resp_obj['id'] == x) # assume replies are in-sequence
if settings['rev_hash_bytes'] == 'true':
resp_obj['result'] = hex_switchEndian(resp_obj['result'])
Expand Down Expand Up @@ -140,7 +140,7 @@ def get_rpc_cookie():
if 'datadir' in settings and not use_userpass:
use_datadir = True
if not use_userpass and not use_datadir:
print("Missing datadir or username and/or password in cfg file", file=stderr)
print("Missing datadir or username and/or password in cfg file", file=sys.stderr)
sys.exit(1)

settings['port'] = int(settings['port'])
Expand Down
2 changes: 1 addition & 1 deletion contrib/seeds/generate-seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def process_nodes(g, f, structname, defaultport):
def main():
if len(sys.argv)<2:
print(('Usage: %s <path_to_nodes_txt>' % sys.argv[0]), file=sys.stderr)
exit(1)
sys.exit(1)
g = sys.stdout
indir = sys.argv[1]
g.write('#ifndef DASH_CHAINPARAMSSEEDS_H\n')
Expand Down
2 changes: 1 addition & 1 deletion contrib/zmq/zmq_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

if not (sys.version_info.major >= 3 and sys.version_info.minor >= 5):
print("This example only works with Python 3.5 and greater")
exit(1)
sys.exit(1)

port = 28332

Expand Down
2 changes: 1 addition & 1 deletion contrib/zmq/zmq_sub3.4.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

if not (sys.version_info.major >= 3 and sys.version_info.minor >= 4):
print("This example only works with Python 3.4 and greater")
exit(1)
sys.exit(1)

port = 28332

Expand Down
2 changes: 1 addition & 1 deletion share/qt/extract_strings_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def parse_po(text):
if not XGETTEXT:
print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr)
print('Please install package "gettext" and re-run \'./configure\'.',file=sys.stderr)
exit(1)
sys.exit(1)
child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE)
(out, err) = child.communicate()

Expand Down
2 changes: 1 addition & 1 deletion src/addrdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CBanEntry
banReason = BanReasonUnknown;
}

std::string banReasonToString()
std::string banReasonToString() const
{
switch (banReason) {
case BanReasonNodeMisbehaving:
Expand Down
4 changes: 2 additions & 2 deletions src/bench/lockedpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ static void BenchLockedPool(benchmark::State& state)

std::vector<void*> addr;
for (int x=0; x<ASIZE; ++x)
addr.push_back(0);
addr.push_back(nullptr);
uint32_t s = 0x12345678;
while (state.KeepRunning()) {
for (int x=0; x<BITER; ++x) {
int idx = s & (addr.size()-1);
if (s & 0x80000000) {
b.free(addr[idx]);
addr[idx] = 0;
addr[idx] = nullptr;
} else if(!addr[idx]) {
addr[idx] = b.alloc((s >> 16) & (MSIZE-1));
}
Expand Down
2 changes: 1 addition & 1 deletion src/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return f
uint256 CCoinsView::GetBestBlock() const { return uint256(); }
std::vector<uint256> CCoinsView::GetHeadBlocks() const { return std::vector<uint256>(); }
bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { return false; }
CCoinsViewCursor *CCoinsView::Cursor() const { return 0; }
CCoinsViewCursor *CCoinsView::Cursor() const { return nullptr; }

bool CCoinsView::HaveCoin(const COutPoint &outpoint) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/dbwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ bool CDBWrapper::IsEmpty()
}

CDBIterator::~CDBIterator() { delete piter; }
bool CDBIterator::Valid() { return piter->Valid(); }
bool CDBIterator::Valid() const { return piter->Valid(); }
void CDBIterator::SeekToFirst() { piter->SeekToFirst(); }
void CDBIterator::Next() { piter->Next(); }

Expand Down
2 changes: 1 addition & 1 deletion src/dbwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class CDBIterator
parent(_parent), piter(_piter) { };
~CDBIterator();

bool Valid();
bool Valid() const;

void SeekToFirst();

Expand Down
4 changes: 2 additions & 2 deletions src/governance/governance-exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class CGovernanceException : public std::exception
strMessage = ostr.str();
}

virtual ~CGovernanceException() throw() {}
virtual ~CGovernanceException() noexcept {}

virtual const char* what() const throw() override
virtual const char* what() const noexcept override
{
return strMessage.c_str();
}
Expand Down
4 changes: 2 additions & 2 deletions src/httprpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class HTTPRPCTimerInterface : public RPCTimerInterface
/* Pre-base64-encoded authentication token */
static std::string strRPCUserColonPass;
/* Stored RPC timer interface (for unregistration) */
static HTTPRPCTimerInterface* httpRPCTimerInterface = 0;
static HTTPRPCTimerInterface* httpRPCTimerInterface = nullptr;

static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const UniValue& id)
{
Expand Down Expand Up @@ -255,6 +255,6 @@ void StopHTTPRPC()
if (httpRPCTimerInterface) {
RPCUnsetTimerInterface(httpRPCTimerInterface);
delete httpRPCTimerInterface;
httpRPCTimerInterface = 0;
httpRPCTimerInterface = nullptr;
}
}
16 changes: 8 additions & 8 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
static const size_t MAX_HEADERS_SIZE = 8192;

/** HTTP request work item */
class HTTPWorkItem : public HTTPClosure
class HTTPWorkItem final : public HTTPClosure
{
public:
HTTPWorkItem(std::unique_ptr<HTTPRequest> _req, const std::string &_path, const HTTPRequestHandler& _func):
Expand Down Expand Up @@ -140,13 +140,13 @@ struct HTTPPathHandler
/** HTTP module state */

//! libevent event loop
static struct event_base* eventBase = 0;
static struct event_base* eventBase = nullptr;
//! HTTP server
struct evhttp* eventHTTP = 0;
struct evhttp* eventHTTP = nullptr;
//! List of subnets to allow RPC connections from
static std::vector<CSubNet> rpc_allow_subnets;
//! Work queue for handling longer requests off the event loop thread
static WorkQueue<HTTPClosure>* workQueue = 0;
static WorkQueue<HTTPClosure>* workQueue = nullptr;
//! Handlers for (sub)paths
std::vector<HTTPPathHandler> pathHandlers;
//! Bound listening sockets
Expand Down Expand Up @@ -474,11 +474,11 @@ void StopHTTPServer()
}
if (eventHTTP) {
evhttp_free(eventHTTP);
eventHTTP = 0;
eventHTTP = nullptr;
}
if (eventBase) {
event_base_free(eventBase);
eventBase = 0;
eventBase = nullptr;
}
LogPrint(BCLog::HTTP, "Stopped HTTP server\n");
}
Expand Down Expand Up @@ -596,9 +596,9 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
}
}
});
ev->trigger(0);
ev->trigger(nullptr);
replySent = true;
req = 0; // transferred back to main thread
req = nullptr; // transferred back to main thread
}

CService HTTPRequest::GetPeer()
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ bool ShutdownRequested()
* chainstate, while keeping user interface out of the common library, which is shared
* between bitcoind, and bitcoin-qt and non-server tools.
*/
class CCoinsViewErrorCatcher : public CCoinsViewBacked
class CCoinsViewErrorCatcher final : public CCoinsViewBacked
{
public:
CCoinsViewErrorCatcher(CCoinsView* view) : CCoinsViewBacked(view) {}
Expand Down
2 changes: 1 addition & 1 deletion src/merkleblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class CPartialMerkleTree
bool fBad;

/** helper function to efficiently calculate the number of nodes at given height in the merkle tree */
unsigned int CalcTreeWidth(int height) {
unsigned int CalcTreeWidth(int height) const {
return (nTransactions+(1 << height)-1) >> height;
}

Expand Down
Loading

0 comments on commit 1da2ac5

Please sign in to comment.