mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Merge #19314: refactor: Use uint16_t instead of unsigned short
1cabbddbca
refactor: Use uint16_t instead of unsigned short (Aaron Hook) Pull request description: I wanted to see if the `up for grabs` label works and looked at PR #17822 originally opend by ahook I saw it had many acks for example by jonatack and practicalswift but needed rebasing. So I checked out the remote branch rebased it resolved three conflicts and continued the rebase. Hope everything is as expected (: ACKs for top commit: sipsorcery: ACK1cabbddbca
. practicalswift: ACK1cabbddbca
-- patch looks correct :) laanwj: ACK1cabbddbca
hebasto: ACK1cabbddbca
, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 0e6bf64f274aae5dacb188358b4d5f65ccb207d4f70922f039bc4ed7934709418ddad19f8bfb7462517427837c3d2bb3f86ef284bb40e87119aad2a1e148d9d6
This commit is contained in:
commit
0d69fdb9a0
@ -8,6 +8,7 @@
|
||||
#include <addrman.h>
|
||||
#include <chainparams.h>
|
||||
#include <clientversion.h>
|
||||
#include <cstdint>
|
||||
#include <hash.h>
|
||||
#include <random.h>
|
||||
#include <streams.h>
|
||||
@ -36,7 +37,7 @@ template <typename Data>
|
||||
bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data& data)
|
||||
{
|
||||
// Generate random temporary filename
|
||||
unsigned short randv = 0;
|
||||
uint16_t randv = 0;
|
||||
GetRandBytes((unsigned char*)&randv, sizeof(randv));
|
||||
std::string tmpfn = strprintf("%s.%04x", prefix, randv);
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
static_assert(MINIUPNPC_API_VERSION >= 10, "miniUPnPc API version >= 10 assumed");
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <math.h>
|
||||
@ -110,9 +111,9 @@ void CConnman::AddOneShot(const std::string& strDest)
|
||||
vOneShots.push_back(strDest);
|
||||
}
|
||||
|
||||
unsigned short GetListenPort()
|
||||
uint16_t GetListenPort()
|
||||
{
|
||||
return (unsigned short)(gArgs.GetArg("-port", Params().GetDefaultPort()));
|
||||
return (uint16_t)(gArgs.GetArg("-port", Params().GetDefaultPort()));
|
||||
}
|
||||
|
||||
// find 'best' local address for a particular peer
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include <uint256.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <stdint.h>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <condition_variable>
|
||||
@ -482,7 +482,7 @@ void Discover();
|
||||
void StartMapPort();
|
||||
void InterruptMapPort();
|
||||
void StopMapPort();
|
||||
unsigned short GetListenPort();
|
||||
uint16_t GetListenPort();
|
||||
|
||||
struct CombinerAll
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <cstdint>
|
||||
#include <netaddress.h>
|
||||
#include <hash.h>
|
||||
#include <util/strencodings.h>
|
||||
@ -627,15 +628,15 @@ CService::CService() : port(0)
|
||||
{
|
||||
}
|
||||
|
||||
CService::CService(const CNetAddr& cip, unsigned short portIn) : CNetAddr(cip), port(portIn)
|
||||
CService::CService(const CNetAddr& cip, uint16_t portIn) : CNetAddr(cip), port(portIn)
|
||||
{
|
||||
}
|
||||
|
||||
CService::CService(const struct in_addr& ipv4Addr, unsigned short portIn) : CNetAddr(ipv4Addr), port(portIn)
|
||||
CService::CService(const struct in_addr& ipv4Addr, uint16_t portIn) : CNetAddr(ipv4Addr), port(portIn)
|
||||
{
|
||||
}
|
||||
|
||||
CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn)
|
||||
CService::CService(const struct in6_addr& ipv6Addr, uint16_t portIn) : CNetAddr(ipv6Addr), port(portIn)
|
||||
{
|
||||
}
|
||||
|
||||
@ -663,7 +664,7 @@ bool CService::SetSockAddr(const struct sockaddr *paddr)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned short CService::GetPort() const
|
||||
uint16_t CService::GetPort() const
|
||||
{
|
||||
return port;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <compat.h>
|
||||
#include <serialize.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -143,10 +143,10 @@ class CService : public CNetAddr
|
||||
|
||||
public:
|
||||
CService();
|
||||
CService(const CNetAddr& ip, unsigned short port);
|
||||
CService(const struct in_addr& ipv4Addr, unsigned short port);
|
||||
CService(const CNetAddr& ip, uint16_t port);
|
||||
CService(const struct in_addr& ipv4Addr, uint16_t port);
|
||||
explicit CService(const struct sockaddr_in& addr);
|
||||
unsigned short GetPort() const;
|
||||
uint16_t GetPort() const;
|
||||
bool GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const;
|
||||
bool SetSockAddr(const struct sockaddr* paddr);
|
||||
friend bool operator==(const CService& a, const CService& b);
|
||||
@ -157,7 +157,7 @@ class CService : public CNetAddr
|
||||
std::string ToStringPort() const;
|
||||
std::string ToStringIPPort() const;
|
||||
|
||||
CService(const struct in6_addr& ipv6Addr, unsigned short port);
|
||||
CService(const struct in6_addr& ipv6Addr, uint16_t port);
|
||||
explicit CService(const struct sockaddr_in6& addr);
|
||||
|
||||
SERIALIZE_METHODS(CService, obj) { READWRITE(obj.ip, Using<BigEndianFormatter<2>>(obj.port)); }
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <util/system.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <fcntl.h>
|
||||
@ -798,11 +799,11 @@ bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int
|
||||
ProxyCredentials random_auth;
|
||||
static std::atomic_int counter(0);
|
||||
random_auth.username = random_auth.password = strprintf("%i", counter++);
|
||||
if (!Socks5(strDest, (unsigned short)port, &random_auth, hSocket)) {
|
||||
if (!Socks5(strDest, (uint16_t)port, &random_auth, hSocket)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Socks5(strDest, (unsigned short)port, 0, hSocket)) {
|
||||
if (!Socks5(strDest, (uint16_t)port, 0, hSocket)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define BITCOIN_QT_OPTIONSMODEL_H
|
||||
|
||||
#include <amount.h>
|
||||
#include <cstdint>
|
||||
#include <qt/guiconstants.h>
|
||||
|
||||
#include <QAbstractListModel>
|
||||
@ -15,7 +16,7 @@ class Node;
|
||||
}
|
||||
|
||||
extern const char *DEFAULT_GUI_PROXY_HOST;
|
||||
static constexpr unsigned short DEFAULT_GUI_PROXY_PORT = 9050;
|
||||
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;
|
||||
|
||||
/**
|
||||
* Convert configured prune target MiB to displayed GB. Round up to avoid underestimating max disk usage.
|
||||
|
@ -9,13 +9,13 @@
|
||||
#include <compat/endian.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <ios>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
@ -272,7 +272,7 @@ template<typename Stream> inline void Unserialize(Stream& s, bool& a) { char f=s
|
||||
inline unsigned int GetSizeOfCompactSize(uint64_t nSize)
|
||||
{
|
||||
if (nSize < 253) return sizeof(unsigned char);
|
||||
else if (nSize <= std::numeric_limits<unsigned short>::max()) return sizeof(unsigned char) + sizeof(unsigned short);
|
||||
else if (nSize <= std::numeric_limits<uint16_t>::max()) return sizeof(unsigned char) + sizeof(uint16_t);
|
||||
else if (nSize <= std::numeric_limits<unsigned int>::max()) return sizeof(unsigned char) + sizeof(unsigned int);
|
||||
else return sizeof(unsigned char) + sizeof(uint64_t);
|
||||
}
|
||||
@ -286,7 +286,7 @@ void WriteCompactSize(Stream& os, uint64_t nSize)
|
||||
{
|
||||
ser_writedata8(os, nSize);
|
||||
}
|
||||
else if (nSize <= std::numeric_limits<unsigned short>::max())
|
||||
else if (nSize <= std::numeric_limits<uint16_t>::max())
|
||||
{
|
||||
ser_writedata8(os, 253);
|
||||
ser_writedata16(os, nSize);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <addrman.h>
|
||||
#include <chainparams.h>
|
||||
#include <clientversion.h>
|
||||
#include <cstdint>
|
||||
#include <net.h>
|
||||
#include <netbase.h>
|
||||
#include <serialize.h>
|
||||
@ -83,10 +84,10 @@ BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup)
|
||||
BOOST_AUTO_TEST_CASE(cnode_listen_port)
|
||||
{
|
||||
// test default
|
||||
unsigned short port = GetListenPort();
|
||||
uint16_t port = GetListenPort();
|
||||
BOOST_CHECK(port == Params().GetDefaultPort());
|
||||
// test set port
|
||||
unsigned short altPort = 12345;
|
||||
uint16_t altPort = 12345;
|
||||
BOOST_CHECK(gArgs.SoftSetArg("-port", ToString(altPort)));
|
||||
port = GetListenPort();
|
||||
BOOST_CHECK(port == altPort);
|
||||
|
Loading…
Reference in New Issue
Block a user