Update ccan/structeq.

structeq() is too dangerous: if a structure has padding, it can fail
silently.

The new ccan/structeq instead provides a macro to define foo_eq(),
which does the right thing in case of padding (which none of our
structures currently have anyway).

Upgrade ccan, and use it everywhere.  Except run-peer-wire.c, which
is only testing code and can use raw memcmp(): valgrind will tell us
if padding exists.

Interestingly, we still declared short_channel_id_eq, even though
we didn't define it any more!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-07-04 15:00:02 +09:30
committed by Christian Decker
parent 4a1ca0fb99
commit fed5a117e7
44 changed files with 172 additions and 140 deletions

View File

@@ -543,7 +543,7 @@ static struct channel *channel_by_channel_id(struct peer *peer,
derive_channel_id(&cid,
&channel->funding_txid,
channel->funding_outnum);
if (structeq(&cid, channel_id))
if (channel_id_eq(&cid, channel_id))
return channel;
}
return NULL;
@@ -997,7 +997,7 @@ command_find_channel(struct command *cmd,
derive_channel_id(&channel_cid,
&channel->funding_txid,
channel->funding_outnum);
if (structeq(&channel_cid, &cid))
if (channel_id_eq(&channel_cid, &cid))
return channel;
}
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
@@ -1437,7 +1437,7 @@ static void json_dev_forget_channel(struct command *cmd, const char *buffer,
if (scidtok) {
if (!channel->scid)
continue;
if (!structeq(channel->scid, &scid))
if (!short_channel_id_eq(channel->scid, &scid))
continue;
}
if (forget->channel) {