Skip to content

Commit

Permalink
Makefile: generalize whitespace check.
Browse files Browse the repository at this point in the history
Spread to individual Makefiles, and include headers.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jan 4, 2017
1 parent 751a0ae commit b7789bf
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 11 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ check-bolt: check-bolt.o $(CCAN_OBJS)

check-bolt.o: $(CCAN_HEADERS)

check-whitespace:
@if grep -n '[ ]$$' Makefile daemon/test/Makefile daemon/Makefile bitcoin/Makefile check-bolt.c $(CORE_SRC) $(BITCOIN_SRC) $(DAEMON_SRC); then echo Extraneous whitespace found >&2; exit 1; fi
check-whitespace/%: %
@if grep -Hn '[ ]$$' $<; then echo Extraneous whitespace found >&2; exit 1; fi

check-whitespace: check-whitespace/Makefile check-whitespace/check-bolt.c $(CORE_SRC:%=check-whitespace/%) $(CORE_HEADERS:%=check-whitespace/%)

check-source: check-makefile check-source-bolt check-whitespace \
$(CORE_SRC:%=check-src-include-order/%) \
Expand Down
2 changes: 2 additions & 0 deletions bitcoin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ check: bitcoin-tests

check-source-bolt: $(BITCOIN_SRC:%=bolt-check/%) $(BITCOIN_HEADERS:%=bolt-check/%)

check-whitespace: $(BITCOIN_SRC:%=check-whitespace/%) $(BITCOIN_HEADERS:%=check-whitespace/%) check-whitespace/bitcoin/Makefile

bitcoin-tests: $(BITCOIN_TEST_PROGRAMS:%=unittest/%)
2 changes: 1 addition & 1 deletion bitcoin/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
/* An address is the RIPEMD160 of the SHA of the public key. */
struct bitcoin_address {
struct ripemd160 addr;
};
};
#endif /* LIGHTNING_BITCOIN_ADDRESS_H */
2 changes: 2 additions & 0 deletions daemon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ check-daemon-makefile:

check-source-bolt: $(DAEMON_SRC:%=bolt-check/%) $(DAEMON_HEADERS:%=bolt-check/%)

check-whitespace: $(DAEMON_SRC:%=check-whitespace/%) $(DAEMON_HEADERS:%=check-whitespace/%) check-whitespace/daemon/Makefile

# Git submodules are seriously broken.
daemon/jsmn/jsmn.h:
git submodule update daemon/jsmn/
Expand Down
2 changes: 1 addition & 1 deletion daemon/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

struct lightningd_state;

/* After this, we're in the .lightning dir, config file parsed.
/* After this, we're in the .lightning dir, config file parsed.
* If we just created the dir, returns true.
*/
bool handle_opts(struct lightningd_state *dstate, int argc, char *argv[]);
Expand Down
2 changes: 1 addition & 1 deletion daemon/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct node_connection {

/* Minimum number of msatoshi in an HTLC */
u32 htlc_minimum_msat;

/* The channel ID, as determined by the anchor transaction */
struct channel_id channel_id;

Expand Down
5 changes: 4 additions & 1 deletion wire/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ wire/gen_wire.o: wire/gen_wire.h
check-source: $(WIRE_SRC:%=check-src-include-order/%) $(WIRE_HEADERS:%=check-hdr-include-order/%)

check-source-bolt: $(WIRE_SRC:%=bolt-check/%) $(WIRE_HEADERS:%=bolt-check/%)

check-whitespace: $(WIRE_SRC:%=check-whitespace/%) $(WIRE_HEADERS:%=check-whitespace/%) check-whitespace/wire/Makefile

clean: wire-clean

wire-all: wire/gen_wire.o wire/fromwire.o wire/towire.o

wire-clean:
$(RM) $(WIRE_OBJS) $(WIRE_GEN_SRC) $(WIRE_GEN_HEADERS) towire.c fromwire.c

include wire/test/Makefile
include wire/test/Makefile
6 changes: 3 additions & 3 deletions wire/fromwire.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ u16 fromwire_u16(const u8 **cursor, size_t *max)
return 0;
return be16_to_cpu(ret);
}

u32 fromwire_u32(const u8 **cursor, size_t *max)
{
be32 ret;
Expand Down Expand Up @@ -102,7 +102,7 @@ void fromwire_channel_id(const u8 **cursor, size_t *max,
fromwire(cursor, max, &outnum, 1);
channel_id->outnum = outnum;
}

void fromwire_sha256(const u8 **cursor, size_t *max, struct sha256 *sha256)
{
fromwire(cursor, max, sha256, sizeof(*sha256));
Expand All @@ -122,7 +122,7 @@ void fromwire_pad_array(const u8 **cursor, size_t *max, u8 *arr, size_t num)
{
fromwire(cursor, max, arr, num);
}

void fromwire_signature_array(const u8 **cursor, size_t *max,
struct signature *arr, size_t num)
{
Expand Down
4 changes: 2 additions & 2 deletions wire/towire.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void towire_channel_id(u8 **pptr, const struct channel_id *channel_id)
{
be32 txnum = cpu_to_be32(channel_id->txnum);
u8 outnum = channel_id->outnum;

towire_u32(pptr, channel_id->blocknum);
towire(pptr, (char *)&txnum + 1, 3);
towire(pptr, &outnum, 1);
Expand Down Expand Up @@ -88,7 +88,7 @@ void towire_pad_array(u8 **pptr, const u8 *arr, size_t num)
tal_resize(pptr, oldsize + num);
memset(*pptr + oldsize, 0, num);
}

void towire_signature_array(u8 **pptr, const struct signature *arr, size_t num)
{
size_t i;
Expand Down

0 comments on commit b7789bf

Please sign in to comment.