check: make sure all files outside contrib/ include "config.h" first.

And turn "" includes into full-path (which makes it easier to put
config.h first, and finds some cases check-includes.sh missed
previously).

config.h sets _GNU_SOURCE which really needs to be done before any
'#includes': we mainly got away with it with glibc, but other platforms
like Alpine may have stricter requirements.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-12-04 21:53:56 +10:30
parent bdabef9a9b
commit 4ffda340d3
246 changed files with 351 additions and 102 deletions

View File

@ -3,11 +3,12 @@
// Copyright (c) 2009-2012 The Bitcoin Developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "address.h"
#include "base58.h"
#include "privkey.h"
#include "pubkey.h"
#include "shadouble.h"
#include "config.h"
#include <bitcoin/address.h>
#include <bitcoin/base58.h>
#include <bitcoin/privkey.h>
#include <bitcoin/pubkey.h>
#include <bitcoin/shadouble.h>
#include <common/utils.h>
#include <wally_core.h>

View File

@ -1,4 +1,5 @@
#include "chainparams.h"
#include "config.h"
#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/feerate.h>
u32 feerate_from_style(u32 feerate, enum feerate_style style)

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/preimage.h>
#include <wire/wire.h>

View File

@ -1,4 +1,5 @@
#include "privkey.h"
#include "config.h"
#include <bitcoin/privkey.h>
#include <ccan/str/hex/hex.h>
#include <common/type_to_string.h>
#include <wire/wire.h>

View File

@ -1,6 +1,7 @@
#include "privkey.h"
#include "pubkey.h"
#include "config.h"
#include <assert.h>
#include <bitcoin/privkey.h>
#include <bitcoin/pubkey.h>
#include <ccan/mem/mem.h>
#include <ccan/str/hex/hex.h>
#include <common/type_to_string.h>

View File

@ -1,9 +1,10 @@
#include "address.h"
#include "locktime.h"
#include "preimage.h"
#include "pubkey.h"
#include "script.h"
#include "config.h"
#include <assert.h>
#include <bitcoin/address.h>
#include <bitcoin/locktime.h>
#include <bitcoin/preimage.h>
#include <bitcoin/pubkey.h>
#include <bitcoin/script.h>
#include <ccan/endian/endian.h>
#include <ccan/mem/mem.h>
#include <common/utils.h>

View File

@ -1,4 +1,5 @@
#include "shadouble.h"
#include "config.h"
#include <bitcoin/shadouble.h>
#include <ccan/mem/mem.h>
#include <common/type_to_string.h>
#include <wire/wire.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/short_channel_id.h>
#include <ccan/tal/str/str.h>
#include <common/type_to_string.h>

View File

@ -1,11 +1,12 @@
#include "privkey.h"
#include "pubkey.h"
#include "script.h"
#include "shadouble.h"
#include "signature.h"
#include "tx.h"
#include "config.h"
#include <assert.h>
#include <bitcoin/privkey.h>
#include <bitcoin/psbt.h>
#include <bitcoin/pubkey.h>
#include <bitcoin/script.h>
#include <bitcoin/shadouble.h>
#include <bitcoin/signature.h>
#include <bitcoin/tx.h>
#include <ccan/mem/mem.h>
#include <common/type_to_string.h>
#include <wire/wire.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../block.c"
#include "../psbt.c"
#include "../shadouble.c"

View File

@ -1,4 +1,5 @@
#include "varint.h"
#include "config.h"
#include <bitcoin/varint.h>
size_t varint_size(varint_t v)
{

View File

@ -1,7 +1,12 @@
#ifndef LIGHTNING_CCAN_COMPAT_H
#define LIGHTNING_CCAN_COMPAT_H
/* Magical file included from config.h (ie. everywhere) which renames
* sha256 routines so they don't clash with libwally-core's internal ones */
/* So, for obvious reasons, this is an exception to the usual rule that we
#include "config.h"
* in all files. */
#define sha256(sha, p, size) ccan_sha256(sha, p, size)
#define sha256_init(ctx) ccan_sha256_init(ctx)
#define sha256_update(ctx, p, size) ccan_sha256_update(ctx, p, size)

View File

@ -10,6 +10,7 @@
* reading and writing synchronously we could deadlock if we hit buffer
* limits, unlikely as that is.
*/
#include "config.h"
#include <ccan/asort/asort.h>
#include <ccan/cast/cast.h>
#include <ccan/mem/mem.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/script.h>
#include <channeld/commit_tx.h>
#include <common/htlc_trim.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <inttypes.h>
#include <stdio.h>
#include <common/type_to_string.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../../common/blockheight_states.c"
#include "../../common/channel_id.c"
#include "../../common/fee_states.c"

View File

@ -1,7 +1,7 @@
#include "watchtower.h"
#include "config.h"
#include <bitcoin/feerate.h>
#include <bitcoin/script.h>
#include <channeld/watchtower.h>
#include <common/features.h>
#include <common/htlc_tx.h>
#include <common/keyset.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/script.h>
#include <ccan/cast/cast.h>
#include <ccan/fdpass/fdpass.h>

View File

@ -1,7 +1,8 @@
#include "addr.h"
#include "config.h"
#include <bitcoin/address.h>
#include <bitcoin/base58.h>
#include <bitcoin/script.h>
#include <common/addr.h>
#include <common/bech32.h>
char *encode_scriptpubkey_to_addr(const tal_t *ctx,

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/str/base32/base32.h>
#include <common/base32.h>

View File

@ -21,9 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "bech32.h"
#include "config.h"
#include <assert.h>
#include <common/bech32.h>
#include <string.h>
static uint32_t bech32_polymod_step(uint32_t pre) {

View File

@ -1,6 +1,7 @@
#include "bech32_util.h"
#include "config.h"
#include <ccan/tal/str/str.h>
#include <common/bech32.h>
#include <common/bech32_util.h>
static u8 get_bit(const u8 *src, size_t bitoff)
{

View File

@ -1,5 +1,6 @@
#include "billboard.h"
#include "config.h"
#include <ccan/ccan/tal/str/str.h>
#include <common/billboard.h>
#include <common/utils.h>
char *billboard_message(const tal_t *ctx,

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/bip32.h>
#include <wally_bip32.h>
#include <wire/wire.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/cast/cast.h>
#include <common/blindedpath.h>
#include <common/blinding.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/privkey.h>
#include <bitcoin/pubkey.h>
#include <common/blinding.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <ccan/tal/str/str.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/address.h>
#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/address.h>
#include <bitcoin/base58.h>
#include <bitcoin/script.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/chainparams.h>
#include <ccan/tal/str/str.h>
#include <common/bech32_util.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/cast/cast.h>
#include <ccan/ilog/ilog.h>
#include <ccan/mem/mem.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/channel_config.h>
#include <wire/wire.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/pubkey.h>
#include <bitcoin/tx.h>
#include <common/channel_id.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <common/channel_type.h>

View File

@ -1,8 +1,8 @@
#include "bitcoin/script.h"
#include "bitcoin/tx.h"
#include "close_tx.h"
#include "permute_tx.h"
#include "config.h"
#include <assert.h>
#include <bitcoin/script.h>
#include <common/close_tx.h>
#include <common/permute_tx.h>
#include <common/utils.h>
struct bitcoin_tx *create_close_tx(const tal_t *ctx,

View File

@ -1,4 +1,4 @@
#include "configdir.h"
#include "config.h"
#include <assert.h>
#include <bitcoin/chainparams.h>
#include <ccan/cast/cast.h>
@ -7,6 +7,7 @@
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <common/configdir.h>
#include <common/utils.h>
#include <common/version.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/crypto_state.h>
#include <wire/wire.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/read_write_all/read_write_all.h>
#include <common/crypto_sync.h>
#include <common/cryptomsg.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/fdpass/fdpass.h>
#include <ccan/io/fdpass/fdpass.h>
#include <common/daemon_conn.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/cast/cast.h>
#include <common/decode_array.h>
#include <wire/peer_wire.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
#include <common/derive_basepoints.h>
#include <common/utils.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <common/descriptor_checksum.h>
#include <stdlib.h>

View File

@ -1,5 +1,6 @@
/* Without this, gheap is *really* slow! Comment out for debugging. */
#define NDEBUG
#include "config.h"
#include <ccan/cast/cast.h>
#include <common/dijkstra.h>
#include <common/gossmap.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/ecdh_hsmd.h>
#include <hsmd/hsmd_wiregen.h>
#include <wire/wire_sync.h>

View File

@ -1,7 +1,8 @@
#include "features.h"
#include "config.h"
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/tal/str/str.h>
#include <common/features.h>
#include <wire/peer_wire.h>
enum feature_copy_style {

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <ccan/tal/str/str.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/crypto/siphash24/siphash24.h>
#include <ccan/htable/htable.h>
#include <common/gossip_rcvd_filter.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/endian/endian.h>
#include <common/hash_u5.h>
#include <string.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/privkey.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/hsm_encryption.h>
#include <termios.h>
#include <unistd.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <common/htlc.h>
#include "htlc_state_names_gen.h"

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/htlc_trim.h>
#include <common/htlc_tx.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/preimage.h>
#include <bitcoin/script.h>
#include <common/htlc_tx.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <ccan/crypto/shachain/shachain.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>
#include <common/initial_commit_tx.h>

View File

@ -1,6 +1,7 @@
#include "io_lock.h"
#include "config.h"
#include <assert.h>
#include <ccan/io/io_plan.h>
#include <common/io_lock.h>
struct io_lock {
bool locked;

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <common/iso4217.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <arpa/inet.h>
#include <bitcoin/psbt.h>
#include <ccan/ccan/str/hex/hex.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/io/io.h>
/* To reach into io_plan: not a public header! */
#include <ccan/io/backend.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/address.h>
#include <bitcoin/base58.h>
#include <bitcoin/feerate.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/privkey.h>
#include <bitcoin/pubkey.h>
#include <common/key_derive.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/derive_basepoints.h>
#include <common/key_derive.h>
#include <common/keyset.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/cast/cast.h>
#include <common/onionreply.h>
#include <common/utils.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/asort/asort.h>
#include <ccan/tal/str/str.h>
#include <common/json_command.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/tal/str/str.h>
#include <common/peer_billboard.h>
#include <common/status.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <assert.h>
#include <ccan/breakpoint/breakpoint.h>
#include <ccan/tal/str/str.h>

View File

@ -1,4 +1,5 @@
#include "permute_tx.h"
#include "config.h"
#include <common/permute_tx.h>
#include <wally_psbt.h>
static bool input_better(const struct wally_tx_input *a,

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/ping.h>
#include <common/status.h>
#include <common/version.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/script.h>
#include <common/psbt_internal.h>
#include <common/psbt_open.h>

View File

@ -1,9 +1,10 @@
#include "pseudorand.h"
#include "config.h"
#include <assert.h>
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/crypto/siphash24/siphash24.h>
#include <ccan/isaac/isaac64.h>
#include <ccan/likely/likely.h>
#include <common/pseudorand.h>
#include <sodium/randombytes.h>
#include <string.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/pseudorand.h>
#include <common/random_select.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <bitcoin/script.h>
#include <common/shutdown_scriptpubkey.h>

View File

@ -1,5 +1,6 @@
#include "socket_close.h"
#include "config.h"
#include <ccan/noerr/noerr.h>
#include <common/socket_close.h>
#include <errno.h>
#include <sys/socket.h>
#include <unistd.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <common/status_levels.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/status_wire.h>
#include <wire/wire.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <common/dev_disconnect.h>
#include <common/status.h>
#include <common/subdaemon.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../amount.c"
#include <common/setup.h>
#include <stdio.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../base64.c"
#include <assert.h>
#include <ccan/base64/base64.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <common/amount.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../bigsize.c"
#include "../blinding.c"
#include "../hmac.c"

View File

@ -1,4 +1,5 @@
/* Pipe through jq for test vector! */
#include "config.h"
#include "../bigsize.c"
#include "../blindedpath.c"
#include "../blinding.c"

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../amount.c"
#include "../bech32.c"
#include "../bech32_util.c"

View File

@ -1,4 +1,5 @@
#define SUPERVERBOSE printf
#include "config.h"
/* Needed before including bolt12_merkle.c: */
#include <common/type_to_string.h>
#include <stdio.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../bolt12.c"
#include "../json.c"
#include <ccan/array_size/array_size.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <ccan/str/hex/hex.h>
#include <common/setup.h>
#include <common/status.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../derive_basepoints.c"
#include <ccan/err/err.h>
#include <ccan/mem/mem.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../features.c"
#include "../memleak.c"
#include <ccan/mem/mem.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../gossip_rcvd_filter.c"
#include "../pseudorand.c"
#include "../../wire/fromwire.c"

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../fp16.c"
#include <common/setup.h>
#include <common/type_to_string.h>

View File

@ -1,4 +1,5 @@
/* Test conversion assumptions used by gossmap_guess_node_id */
#include "config.h"
#include "../node_id.c"
#include <bitcoin/privkey.h>
#include <common/amount.h>

View File

@ -1,4 +1,5 @@
/* Test local modifications to gossmap */
#include "config.h"
#include "../amount.c"
#include "../fp16.c"
#include "../gossmap.c"

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../common/base32.c"
#include "../common/wireaddr.c"

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../json_helpers.c"
#include <assert.h>
#include <ccan/tal/str/str.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../json.c"
#include <common/amount.h>
#include <common/setup.h>

View File

@ -1,5 +1,6 @@
#define SUPERVERBOSE
#include "config.h"
#include <ccan/str/hex/hex.h>
#include <common/amount.h>
#include <common/setup.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../amount.c"
#include "../lease_rates.c"
#include <common/setup.h>

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "../io_lock.c"
#include <common/amount.h>
#include <common/setup.h>

View File

@ -5,6 +5,7 @@
* getchannels:
* {'channels': [{'active': True, 'short_id': '6990x2x1/1', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06', 'last_update': 1504064344}, {'active': True, 'short_id': '6989x2x1/0', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 0, 'destination': '03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf', 'source': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'last_update': 1504064344}, {'active': True, 'short_id': '6990x2x1/0', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 0, 'destination': '02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06', 'source': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'last_update': 1504064344}, {'active': True, 'short_id': '6989x2x1/1', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf', 'last_update': 1504064344}]}
*/
#include "config.h"
#include <assert.h>
#include <common/channel_type.h>
#include <common/dijkstra.h>

Some files were not shown because too many files have changed in this diff Show More