Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripted-diff: Replace deprecated C headers #14905

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/developer-notes.md
Expand Up @@ -650,6 +650,8 @@ Source code organization
failures when those indirect dependencies change. Furthermore, it obscures what the real code
dependencies are.

- Use `#include <cxxx>` instead of the deprecated form `#include <xxx.h>` when including C compatibility headers (such as `<cstdint>`, `<cstdlib>`, `<cstring>`, etc.).

- Don't import anything into the global namespace (`using namespace ...`). Use
fully specified types such as `std::string`.

Expand Down
2 changes: 1 addition & 1 deletion src/addrman.h
Expand Up @@ -13,9 +13,9 @@
#include <timedata.h>
#include <util/system.h>

#include <cstdint>
#include <map>
#include <set>
#include <stdint.h>
#include <vector>

/**
Expand Down
2 changes: 1 addition & 1 deletion src/amount.h
Expand Up @@ -6,7 +6,7 @@
#ifndef BITCOIN_AMOUNT_H
#define BITCOIN_AMOUNT_H

#include <stdint.h>
#include <cstdint>

/** Amount in satoshis (Can be negative) */
typedef int64_t CAmount;
Expand Down
4 changes: 2 additions & 2 deletions src/arith_uint256.cpp
Expand Up @@ -9,8 +9,8 @@
#include <util/strencodings.h>
#include <crypto/common.h>

#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>

template <unsigned int BITS>
base_uint<BITS>::base_uint(const std::string& str)
Expand Down
4 changes: 2 additions & 2 deletions src/arith_uint256.h
Expand Up @@ -6,11 +6,11 @@
#ifndef BITCOIN_ARITH_UINT256_H
#define BITCOIN_ARITH_UINT256_H

#include <assert.h>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <limits>
#include <stdexcept>
#include <stdint.h>
#include <string>
#include <vector>

Expand Down
4 changes: 2 additions & 2 deletions src/base58.cpp
Expand Up @@ -8,8 +8,8 @@
#include <uint256.h>
#include <util/strencodings.h>

#include <assert.h>
#include <string.h>
#include <cassert>
#include <cstring>

/** All alphanumeric characters except for "0", "I", "O", and "l" */
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
Expand Down
2 changes: 1 addition & 1 deletion src/bech32.h
Expand Up @@ -12,7 +12,7 @@
#ifndef BITCOIN_BECH32_H
#define BITCOIN_BECH32_H

#include <stdint.h>
#include <cstdint>
#include <string>
#include <vector>

Expand Down
8 changes: 4 additions & 4 deletions src/bench/bench.cpp
Expand Up @@ -4,12 +4,12 @@

#include <bench/bench.h>

#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <regex>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <regex>

void benchmark::ConsolePrinter::header()
{
Expand Down
2 changes: 1 addition & 1 deletion src/bench/examples.cpp
Expand Up @@ -18,7 +18,7 @@ static void Sleep100ms(benchmark::State& state)
BENCHMARK(Sleep100ms, 10);

// Extremely fast-running benchmark:
#include <math.h>
#include <cmath>

volatile double sum = 0.0; // volatile, global so not optimized away

Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-cli.cpp
Expand Up @@ -15,8 +15,8 @@
#include <util/system.h>
#include <util/strencodings.h>

#include <cstdio>
#include <memory>
#include <stdio.h>
#include <tuple>

#include <event2/buffer.h>
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-tx.cpp
Expand Up @@ -22,8 +22,8 @@
#include <util/moneystr.h>
#include <util/strencodings.h>

#include <cstdio>
#include <memory>
#include <stdio.h>

#include <boost/algorithm/string.hpp>

Expand Down
2 changes: 1 addition & 1 deletion src/bitcoind.cpp
Expand Up @@ -22,7 +22,7 @@
#include <util/strencodings.h>
#include <walletinitinterface.h>

#include <stdio.h>
#include <cstdio>

const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion src/blockfilter.h
Expand Up @@ -5,7 +5,7 @@
#ifndef BITCOIN_BLOCKFILTER_H
#define BITCOIN_BLOCKFILTER_H

#include <stdint.h>
#include <cstdint>
#include <unordered_set>
#include <vector>

Expand Down
4 changes: 2 additions & 2 deletions src/bloom.cpp
Expand Up @@ -11,8 +11,8 @@
#include <random.h>
#include <streams.h>

#include <math.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>


#define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455
Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Expand Up @@ -12,7 +12,7 @@
#include <util/strencodings.h>
#include <versionbitsinfo.h>

#include <assert.h>
#include <cassert>

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/chainparamsbase.cpp
Expand Up @@ -9,7 +9,7 @@
#include <util/system.h>
#include <util/memory.h>

#include <assert.h>
#include <cassert>

const std::string CBaseChainParams::MAIN = "main";
const std::string CBaseChainParams::TESTNET = "test";
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoints.cpp
Expand Up @@ -9,7 +9,7 @@
#include <reverse_iterator.h>
#include <validation.h>

#include <stdint.h>
#include <cstdint>


namespace Checkpoints {
Expand Down
4 changes: 2 additions & 2 deletions src/coins.h
Expand Up @@ -14,8 +14,8 @@
#include <serialize.h>
#include <uint256.h>

#include <assert.h>
#include <stdint.h>
#include <cassert>
#include <cstdint>

#include <unordered_map>

Expand Down
18 changes: 9 additions & 9 deletions src/compat.h
Expand Up @@ -28,29 +28,29 @@

#include <winsock2.h> // Must be included before mswsock.h and windows.h

#include <cstdint>
#include <mswsock.h>
#include <windows.h>
#include <ws2tcpip.h>
#include <stdint.h>
#else
#include <arpa/inet.h>
#include <climits>
#include <fcntl.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/mman.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <limits.h>
#include <netdb.h>
#include <unistd.h>
#endif

#ifndef WIN32
typedef unsigned int SOCKET;
#include <errno.h>
#include <cerrno>
#define WSAGetLastError() errno
#define WSAEINVAL EINVAL
#define WSAEALREADY EALREADY
Expand Down
2 changes: 1 addition & 1 deletion src/compat/byteswap.h
Expand Up @@ -9,7 +9,7 @@
#include <config/bitcoin-config.h>
#endif

#include <stdint.h>
#include <cstdint>

#if defined(HAVE_BYTESWAP_H)
#include <byteswap.h>
Expand Down
2 changes: 1 addition & 1 deletion src/compat/endian.h
Expand Up @@ -11,7 +11,7 @@

#include <compat/byteswap.h>

#include <stdint.h>
#include <cstdint>

#if defined(HAVE_ENDIAN_H)
#include <endian.h>
Expand Down
4 changes: 2 additions & 2 deletions src/consensus/consensus.h
Expand Up @@ -6,8 +6,8 @@
#ifndef BITCOIN_CONSENSUS_CONSENSUS_H
#define BITCOIN_CONSENSUS_CONSENSUS_H

#include <stdlib.h>
#include <stdint.h>
#include <cstdint>
#include <cstdlib>

/** The maximum allowed size for a serialized block, in bytes (only for buffer size limits) */
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4000000;
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/merkle.h
Expand Up @@ -5,7 +5,7 @@
#ifndef BITCOIN_CONSENSUS_MERKLE_H
#define BITCOIN_CONSENSUS_MERKLE_H

#include <stdint.h>
#include <cstdint>
#include <vector>

#include <primitives/transaction.h>
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/tx_verify.h
Expand Up @@ -7,7 +7,7 @@

#include <amount.h>

#include <stdint.h>
#include <cstdint>
#include <vector>

class CBlockIndex;
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/aes.cpp
Expand Up @@ -5,8 +5,8 @@
#include <crypto/aes.h>
#include <crypto/common.h>

#include <assert.h>
#include <string.h>
#include <cassert>
#include <cstring>

extern "C" {
#include <crypto/ctaes/ctaes.c>
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/chacha20.cpp
Expand Up @@ -8,7 +8,7 @@
#include <crypto/common.h>
#include <crypto/chacha20.h>

#include <string.h>
#include <cstring>

constexpr static inline uint32_t rotl32(uint32_t v, int c) { return (v << c) | (v >> (32 - c)); }

Expand Down
4 changes: 2 additions & 2 deletions src/crypto/chacha20.h
Expand Up @@ -5,8 +5,8 @@
#ifndef BITCOIN_CRYPTO_CHACHA20_H
#define BITCOIN_CRYPTO_CHACHA20_H

#include <stdint.h>
#include <stdlib.h>
#include <cstdint>
#include <cstdlib>

/** A PRNG class for ChaCha20. */
class ChaCha20
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/common.h
Expand Up @@ -9,8 +9,8 @@
#include <config/bitcoin-config.h>
#endif

#include <stdint.h>
#include <string.h>
#include <cstdint>
#include <cstring>

#include <compat/endian.h>

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/hmac_sha256.cpp
Expand Up @@ -4,7 +4,7 @@

#include <crypto/hmac_sha256.h>

#include <string.h>
#include <cstring>

CHMAC_SHA256::CHMAC_SHA256(const unsigned char* key, size_t keylen)
{
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/hmac_sha256.h
Expand Up @@ -7,8 +7,8 @@

#include <crypto/sha256.h>

#include <stdint.h>
#include <stdlib.h>
#include <cstdint>
#include <cstdlib>

/** A hasher class for HMAC-SHA-256. */
class CHMAC_SHA256
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/hmac_sha512.cpp
Expand Up @@ -4,7 +4,7 @@

#include <crypto/hmac_sha512.h>

#include <string.h>
#include <cstring>

CHMAC_SHA512::CHMAC_SHA512(const unsigned char* key, size_t keylen)
{
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/hmac_sha512.h
Expand Up @@ -7,8 +7,8 @@

#include <crypto/sha512.h>

#include <stdint.h>
#include <stdlib.h>
#include <cstdint>
#include <cstdlib>

/** A hasher class for HMAC-SHA-512. */
class CHMAC_SHA512
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/ripemd160.cpp
Expand Up @@ -6,7 +6,7 @@

#include <crypto/common.h>

#include <string.h>
#include <cstring>

// Internal implementation code.
namespace
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/ripemd160.h
Expand Up @@ -5,8 +5,8 @@
#ifndef BITCOIN_CRYPTO_RIPEMD160_H
#define BITCOIN_CRYPTO_RIPEMD160_H

#include <stdint.h>
#include <stdlib.h>
#include <cstdint>
#include <cstdlib>

/** A hasher class for RIPEMD-160. */
class CRIPEMD160
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/sha1.cpp
Expand Up @@ -6,7 +6,7 @@

#include <crypto/common.h>

#include <string.h>
#include <cstring>

// Internal implementation code.
namespace
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/sha1.h
Expand Up @@ -5,8 +5,8 @@
#ifndef BITCOIN_CRYPTO_SHA1_H
#define BITCOIN_CRYPTO_SHA1_H

#include <stdint.h>
#include <stdlib.h>
#include <cstdint>
#include <cstdlib>

/** A hasher class for SHA1. */
class CSHA1
Expand Down